Spaces:
Runtime error
Runtime error
abhilash1910
commited on
Commit
•
90d09a3
1
Parent(s):
d134a48
Initial commit
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import Image
|
2 |
+
import tensorflow
|
3 |
+
import gradio as gr
|
4 |
+
from tensorflow.keras.models import load_model
|
5 |
+
model = load_model('model')
|
6 |
+
def infer(img):
|
7 |
+
cartoonGAN = model.signatures["serving_default"]
|
8 |
+
img = np.array(img.convert("RGB"))
|
9 |
+
img = np.expand_dims(img, 0).astype(np.float32) / 127.5 - 1
|
10 |
+
out = cartoonGAN(tf.constant(img))['output_1']
|
11 |
+
out = ((out.numpy().squeeze() + 1) * 127.5).astype(np.uint8)
|
12 |
+
return out
|
13 |
+
|
14 |
+
|
15 |
+
title = "CartoonGAN"
|
16 |
+
description = "Gradio Demo for AnimeGanv2 Face Portrait. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below."
|
17 |
+
|
18 |
+
#description = "Gradio Demo for AnimeGanv2 Face Portrait. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below."
|
19 |
+
iface = gr.Interface(infer, gr.inputs.Image(type="pil"), "image",title=title,description=description)
|
20 |
+
iface.launch()
|
model/saved_model.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:91ee0cf957489e48506c40ef2aea41e0484a331ece6b5ca5aa12c15bf594e339
|
3 |
+
size 2082535
|
model/variables/variables.data-00000-of-00002
ADDED
Binary file (3.55 MB). View file
|
|
model/variables/variables.data-00001-of-00002
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
��3�e{"class_name": "Sequential", "config": {"layers": [{"class_name": "ZeroPadding2D", "config": {"data_format": "channels_last", "dtype": "float32", "name": "zero_padding2d_1", "padding": [[2, 2], [2, 2]], "trainable": true}}, {"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 3, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [5, 5], "name": "conv2d_29", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": true}}], "name": "sequential_20"}}{�~Y{"class_name": "Activation", "config": {"activation": "tanh", "dtype": "float32", "name": "activation", "trainable": true}}�
|
2 |
+
I��3{"class_name": "Sequential", "config": {"layers": [{"class_name": "ZeroPadding2D", "config": {"data_format": "channels_last", "dtype": "float32", "name": "zero_padding2d", "padding": [[2, 2], [2, 2]], "trainable": true}}, {"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 96, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [5, 5], "name": "conv2d", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": true}}, {"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization", "scale": true, "trainable": true}}, {"class_name": "ReLU", "config": {"dtype": "float32", "max_value": null, "name": "re_lu", "negative_slope": 0.0, "threshold": 0.0, "trainable": true}}], "name": "sequential"}}�
|
3 |
+
��{"class_name": "Sequential", "config": {"layers": [{"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 96, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [1, 1], "name": "conv2d_24", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": false}}, {"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_33", "scale": true, "trainable": true}}, {"class_name": "ReLU", "config": {"dtype": "float32", "max_value": null, "name": "re_lu_21", "negative_slope": 0.0, "threshold": 0.0, "trainable": true}}, {"class_name": "DepthwiseConv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "depth_multiplier": 1, "depthwise_constraint": null, "depthwise_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "depthwise_regularizer": null, "dilation_rate": [1, 1], "dtype": "float32", "kernel_size": [3, 3], "name": "depthwise_conv2d_12", "padding": "same", "strides": [1, 1], "trainable": true, "use_bias": false}}, {"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_34", "scale": true, "trainable": true}}, {"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 96, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [1, 1], "name": "conv2d_25", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": false}}, {"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_35", "scale": true, "trainable": true}}, {"class_name": "ReLU", "config": {"dtype": "float32", "max_value": null, "name": "re_lu_22", "negative_slope": 0.0, "threshold": 0.0, "trainable": true}}], "name": "sequential_16"}}�h
|
4 |
+
��{"class_name": "Sequential", "config": {"layers": [{"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 48, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [1, 1], "name": "conv2d_27", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": false}}, {"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_36", "scale": true, "trainable": true}}, {"class_name": "ReLU", "config": {"dtype": "float32", "max_value": null, "name": "re_lu_23", "negative_slope": 0.0, "threshold": 0.0, "trainable": true}}, {"class_name": "DepthwiseConv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "depth_multiplier": 1, "depthwise_constraint": null, "depthwise_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "depthwise_regularizer": null, "dilation_rate": [1, 1], "dtype": "float32", "kernel_size": [3, 3], "name": "depthwise_conv2d_13", "padding": "same", "strides": [1, 1], "trainable": true, "use_bias": false}}, {"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_37", "scale": true, "trainable": true}}, {"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 48, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [1, 1], "name": "conv2d_28", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": false}}, {"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_38", "scale": true, "trainable": true}}, {"class_name": "ReLU", "config": {"dtype": "float32", "max_value": null, "name": "re_lu_24", "negative_slope": 0.0, "threshold": 0.0, "trainable": true}}], "name": "sequential_18"}}�mח�{"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 96, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [1, 1], "name": "conv2d_24", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": false}}����{"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_33", "scale": true, "trainable": true}}����{"class_name": "ReLU", "config": {"dtype": "float32", "max_value": null, "name": "re_lu_21", "negative_slope": 0.0, "threshold": 0.0, "trainable": true}}����{"class_name": "DepthwiseConv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "depth_multiplier": 1, "depthwise_constraint": null, "depthwise_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "depthwise_regularizer": null, "dilation_rate": [1, 1], "dtype": "float32", "kernel_size": [3, 3], "name": "depthwise_conv2d_12", "padding": "same", "strides": [1, 1], "trainable": true, "use_bias": false}}����{"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_34", "scale": true, "trainable": true}}�mח�{"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 96, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [1, 1], "name": "conv2d_25", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": false}}����{"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_35", "scale": true, "trainable": true}}����{"class_name": "ReLU", "config": {"dtype": "float32", "max_value": null, "name": "re_lu_22", "negative_slope": 0.0, "threshold": 0.0, "trainable": true}}�mח�{"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 48, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [1, 1], "name": "conv2d_27", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": false}}����{"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_36", "scale": true, "trainable": true}}����{"class_name": "ReLU", "config": {"dtype": "float32", "max_value": null, "name": "re_lu_23", "negative_slope": 0.0, "threshold": 0.0, "trainable": true}}����{"class_name": "DepthwiseConv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "depth_multiplier": 1, "depthwise_constraint": null, "depthwise_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "depthwise_regularizer": null, "dilation_rate": [1, 1], "dtype": "float32", "kernel_size": [3, 3], "name": "depthwise_conv2d_13", "padding": "same", "strides": [1, 1], "trainable": true, "use_bias": false}}����{"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_37", "scale": true, "trainable": true}}�mח�{"class_name": "Conv2D", "config": {"activation": "linear", "activity_regularizer": null, "bias_constraint": null, "bias_initializer": {"class_name": "Zeros", "config": {}}, "bias_regularizer": null, "data_format": "channels_last", "dilation_rate": [1, 1], "dtype": "float32", "filters": 48, "kernel_constraint": null, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "kernel_regularizer": null, "kernel_size": [1, 1], "name": "conv2d_28", "padding": "valid", "strides": [1, 1], "trainable": true, "use_bias": false}}����{"class_name": "InstanceNormalization", "config": {"axis": null, "beta_constraint": null, "beta_initializer": {"class_name": "Zeros", "config": {}}, "beta_regularizer": null, "center": true, "dtype": "float32", "epsilon": 0.001, "gamma_constraint": null, "gamma_initializer": {"class_name": "Ones", "config": {}}, "gamma_regularizer": null, "name": "instance_normalization_38", "scale": true, "trainable": true}}����{"class_name": "ReLU", "config": {"dtype": "float32", "max_value": null, "name": "re_lu_24", "negative_slope": 0.0, "threshold": 0.0, "trainable": true}}
|
model/variables/variables.index
ADDED
Binary file (15.5 kB). View file
|
|