Spaces:
Runtime error
Runtime error
Gradio2
Browse files
Kirby.png
ADDED
app.py
CHANGED
@@ -3,15 +3,21 @@ import numpy as np
|
|
3 |
import gradio as gr
|
4 |
from glob import glob
|
5 |
from huggingface_hub import from_pretrained_keras
|
|
|
|
|
6 |
|
7 |
model = from_pretrained_keras('Rietta/CycleGAN_DL', compile=False)
|
8 |
|
|
|
|
|
9 |
def transform(img, direction):
|
10 |
img = (img / 127.5) - 1
|
11 |
if direction==0:
|
|
|
|
|
12 |
pred = model.generator_sims.predict(img[None,:,:,:])[0]
|
13 |
else:
|
14 |
-
pred =
|
15 |
pred = (pred-pred.min())/(pred.max()-pred.min())
|
16 |
pred = (pred * 255).astype(np.uint8)
|
17 |
return pred
|
@@ -22,7 +28,7 @@ def transform(img, direction):
|
|
22 |
|
23 |
demo = gr.Interface(fn=transform,
|
24 |
inputs=[gr.inputs.Image(shape=(256, 256), type='numpy'),
|
25 |
-
gr.inputs.Radio(choices=['Sims', 'Warcraft'],
|
26 |
type='index')],
|
27 |
outputs=gr.outputs.Image(type='numpy'))
|
28 |
#examples=examples)
|
|
|
3 |
import gradio as gr
|
4 |
from glob import glob
|
5 |
from huggingface_hub import from_pretrained_keras
|
6 |
+
import cv2
|
7 |
+
|
8 |
|
9 |
model = from_pretrained_keras('Rietta/CycleGAN_DL', compile=False)
|
10 |
|
11 |
+
imagen = cv2.imread('Kirby.png', cv2.COLOR_BGR2RGB)
|
12 |
+
|
13 |
def transform(img, direction):
|
14 |
img = (img / 127.5) - 1
|
15 |
if direction==0:
|
16 |
+
pred = model.generator_wow.predict(img[None,:,:,:])[0]
|
17 |
+
elif direction == 1:
|
18 |
pred = model.generator_sims.predict(img[None,:,:,:])[0]
|
19 |
else:
|
20 |
+
pred = imagen
|
21 |
pred = (pred-pred.min())/(pred.max()-pred.min())
|
22 |
pred = (pred * 255).astype(np.uint8)
|
23 |
return pred
|
|
|
28 |
|
29 |
demo = gr.Interface(fn=transform,
|
30 |
inputs=[gr.inputs.Image(shape=(256, 256), type='numpy'),
|
31 |
+
gr.inputs.Radio(choices=['Sims', 'Warcraft', "Kirby"],
|
32 |
type='index')],
|
33 |
outputs=gr.outputs.Image(type='numpy'))
|
34 |
#examples=examples)
|