Spaces:
Runtime error
Runtime error
SerdarHelli
commited on
Commit
·
dad6ea4
1
Parent(s):
728f8d7
Update app.py
Browse files
app.py
CHANGED
@@ -41,26 +41,36 @@ with open(network_pkl, 'rb') as f:
|
|
41 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
42 |
G.eval()
|
43 |
G.to(device)
|
44 |
-
def predict(Seed,choices):
|
45 |
|
46 |
shuffle_seed=None
|
47 |
-
w_frames=30*4
|
48 |
kind='cubic'
|
49 |
num_keyframes=None
|
50 |
wraps=2
|
51 |
psi=1
|
|
|
52 |
|
53 |
|
54 |
if choices=='4x2':
|
55 |
grid_w = 4
|
56 |
grid_h = 2
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
59 |
if choices=='2x1':
|
60 |
grid_w = 2
|
61 |
grid_h = 1
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
|
66 |
mp4='ex.mp4'
|
@@ -114,10 +124,14 @@ def predict(Seed,choices):
|
|
114 |
|
115 |
|
116 |
choices=['4x2','2x1']
|
|
|
|
|
117 |
interface=gr.Interface(fn=predict, title="Brain MR Image Generation with StyleGAN-2",
|
118 |
description = "",
|
119 |
article = "Author: S.Serdar Helli",
|
120 |
-
inputs=[gr.inputs.Slider( minimum=16, maximum=2**10,label='Seed'),gr.inputs.Radio( choices=choices, default='4x2',label='Image Grid')
|
|
|
|
|
121 |
outputs=gr.outputs.Video(label='Video'),
|
122 |
live=False)
|
123 |
|
|
|
41 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
42 |
G.eval()
|
43 |
G.to(device)
|
44 |
+
def predict(Seed,choices,choices2):
|
45 |
|
46 |
shuffle_seed=None
|
|
|
47 |
kind='cubic'
|
48 |
num_keyframes=None
|
49 |
wraps=2
|
50 |
psi=1
|
51 |
+
s1=Seed
|
52 |
|
53 |
|
54 |
if choices=='4x2':
|
55 |
grid_w = 4
|
56 |
grid_h = 2
|
57 |
+
if choices2=="Large Video":
|
58 |
+
seeds=(np.arange(s1-16,s1)).tolist()
|
59 |
+
w_frames=60*4
|
60 |
+
if choices2=="Small Video":
|
61 |
+
seeds=(np.arange(s1-8,s1)).tolist()
|
62 |
+
w_frames=30*4
|
63 |
+
|
64 |
if choices=='2x1':
|
65 |
grid_w = 2
|
66 |
grid_h = 1
|
67 |
+
if choices2=="Large Video":
|
68 |
+
seeds=(np.arange(s1-4,s1)).tolist()
|
69 |
+
w_frames=60*4
|
70 |
+
if choices2=="Small Video":
|
71 |
+
seeds=(np.arange(s1-2,s1)).tolist()
|
72 |
+
w_frames=30*4
|
73 |
+
|
74 |
|
75 |
|
76 |
mp4='ex.mp4'
|
|
|
124 |
|
125 |
|
126 |
choices=['4x2','2x1']
|
127 |
+
choices2=["Large Video","Small Video"]
|
128 |
+
|
129 |
interface=gr.Interface(fn=predict, title="Brain MR Image Generation with StyleGAN-2",
|
130 |
description = "",
|
131 |
article = "Author: S.Serdar Helli",
|
132 |
+
inputs=[gr.inputs.Slider( minimum=16, maximum=2**10,label='Seed'),gr.inputs.Radio( choices=choices, default='4x2',label='Image Grid'),
|
133 |
+
,gr.inputs.Radio( choices=choices2, default="Small Video",label='Video Size - It depends on usage of cuda')]],
|
134 |
+
|
135 |
outputs=gr.outputs.Video(label='Video'),
|
136 |
live=False)
|
137 |
|