Spaces:
Runtime error
Runtime error
:tada: First Commit
Browse files- Examples/gta_0.jpg +0 -0
- Examples/gta_1.jpg +0 -0
- Examples/gta_2.jpg +0 -0
- Examples/gta_3.jpg +0 -0
- Examples/gta_4.jpg +0 -0
- Examples/real_0.jpg +0 -0
- Examples/real_1.jpg +0 -0
- Examples/real_2.jpg +0 -0
- Examples/real_3.jpg +0 -0
- Examples/real_4.jpg +0 -0
- app.py +31 -0
- requirements.txt +1 -0
Examples/gta_0.jpg
ADDED
![]() |
Examples/gta_1.jpg
ADDED
![]() |
Examples/gta_2.jpg
ADDED
![]() |
Examples/gta_3.jpg
ADDED
![]() |
Examples/gta_4.jpg
ADDED
![]() |
Examples/real_0.jpg
ADDED
![]() |
Examples/real_1.jpg
ADDED
![]() |
Examples/real_2.jpg
ADDED
![]() |
Examples/real_3.jpg
ADDED
![]() |
Examples/real_4.jpg
ADDED
![]() |
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from random import choices
|
2 |
+
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('Jorgvt/CycleGAN_GTA_REAL', compile=False)
|
8 |
+
|
9 |
+
def transform(img, direction):
|
10 |
+
img = (img / 127.5) - 1
|
11 |
+
if direction==0:
|
12 |
+
pred = model.generator_g.predict(img[None,:,:,:])[0]
|
13 |
+
else:
|
14 |
+
pred = model.generator_f.predict(img[None,:,:,:])[0]
|
15 |
+
pred = (pred-pred.min())/(pred.max()-pred.min())
|
16 |
+
pred = (pred * 255).astype(np.uint8)
|
17 |
+
return pred
|
18 |
+
|
19 |
+
examples_gta = [[path, 'GTA->REAL'] for path in glob('Examples/gta*')]
|
20 |
+
examples_real = [[path, 'REAL->GTA'] for path in glob('Examples/real*')]
|
21 |
+
examples = [*examples_gta, *examples_real]
|
22 |
+
|
23 |
+
demo = gr.Interface(fn=transform,
|
24 |
+
inputs=[gr.inputs.Image(shape=(256, 256), type='numpy'),
|
25 |
+
gr.inputs.Radio(choices=['GTA->REAL', 'REAL->GTA'],
|
26 |
+
type='index')],
|
27 |
+
outputs=gr.outputs.Image(type='numpy'),
|
28 |
+
examples=examples)
|
29 |
+
|
30 |
+
if __name__ == '__main__':
|
31 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
tensorflow>2.6
|