Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse filesHi
@addsw11
, ZeroGPU now supports dynamic duration (see https://huggingface.co/spaces/zero-gpu-explorers/README/discussions/87#66953574e6f56b380176761c)
PS: I did not test the change so merge carefully
app.py
CHANGED
@@ -135,92 +135,17 @@ def generate_image(prompt, image):
|
|
135 |
|
136 |
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
return generate_image(prompt, image)
|
141 |
-
|
142 |
-
@spaces.GPU(duration=70)
|
143 |
-
def generate_image_70(prompt, image):
|
144 |
-
return generate_image(prompt, image)
|
145 |
-
|
146 |
-
@spaces.GPU(duration=90)
|
147 |
-
def generate_image_90(prompt, image):
|
148 |
-
return generate_image(prompt, image)
|
149 |
-
|
150 |
-
@spaces.GPU(duration=110)
|
151 |
-
def generate_image_110(prompt, image):
|
152 |
-
return generate_image(prompt, image)
|
153 |
-
|
154 |
-
@spaces.GPU(duration=130)
|
155 |
-
def generate_image_130(prompt, image):
|
156 |
-
return generate_image(prompt, image)
|
157 |
-
|
158 |
-
@spaces.GPU(duration=150)
|
159 |
-
def generate_image_150(prompt, image):
|
160 |
-
return generate_image(prompt, image)
|
161 |
-
|
162 |
-
@spaces.GPU(duration=170)
|
163 |
-
def generate_image_170(prompt, image):
|
164 |
-
return generate_image(prompt, image)
|
165 |
-
|
166 |
-
@spaces.GPU(duration=190)
|
167 |
-
def generate_image_190(prompt, image):
|
168 |
-
return generate_image(prompt, image)
|
169 |
-
|
170 |
-
@spaces.GPU(duration=200)
|
171 |
-
def generate_image_200(prompt, image):
|
172 |
-
return generate_image(prompt, image)
|
173 |
-
|
174 |
-
@spaces.GPU(duration=210)
|
175 |
-
def generate_image_210(prompt, image):
|
176 |
-
return generate_image(prompt, image)
|
177 |
-
|
178 |
-
@spaces.GPU(duration=220)
|
179 |
-
def generate_image_220(prompt, image):
|
180 |
-
return generate_image(prompt, image)
|
181 |
|
182 |
-
@spaces.GPU(duration=
|
183 |
-
def
|
184 |
return generate_image(prompt, image)
|
185 |
|
186 |
-
@spaces.GPU(duration=240)
|
187 |
-
def generate_image_240(prompt, image):
|
188 |
-
return generate_image(prompt, image)
|
189 |
-
|
190 |
-
|
191 |
-
def generate_image_wrapper(prompt, image, duration):
|
192 |
-
if duration == "50":
|
193 |
-
return generate_image_50(prompt, image)
|
194 |
-
elif duration == "70":
|
195 |
-
return generate_image_70(prompt, image)
|
196 |
-
elif duration == "90":
|
197 |
-
return generate_image_90(prompt, image)
|
198 |
-
elif duration == "110":
|
199 |
-
return generate_image_110(prompt, image)
|
200 |
-
elif duration == "130":
|
201 |
-
return generate_image_130(prompt, image)
|
202 |
-
elif duration == "150":
|
203 |
-
return generate_image_150(prompt, image)
|
204 |
-
elif duration == "170":
|
205 |
-
return generate_image_170(prompt, image)
|
206 |
-
elif duration == "190":
|
207 |
-
return generate_image_190(prompt, image)
|
208 |
-
elif duration == "200":
|
209 |
-
return generate_image_200(prompt, image)
|
210 |
-
elif duration == "210":
|
211 |
-
return generate_image_210(prompt, image)
|
212 |
-
elif duration == "220":
|
213 |
-
return generate_image_220(prompt, image)
|
214 |
-
elif duration == "230":
|
215 |
-
return generate_image_230(prompt, image)
|
216 |
-
elif duration == "240":
|
217 |
-
return generate_image_240(prompt, image)
|
218 |
-
else:
|
219 |
-
return generate_image_170(prompt, image)
|
220 |
|
221 |
if __name__ == "__main__":
|
222 |
demo = gr.Interface(
|
223 |
-
fn=
|
224 |
inputs=[
|
225 |
"text",
|
226 |
gr.Image(image_mode='RGBA', type="numpy"),
|
|
|
135 |
|
136 |
|
137 |
|
138 |
+
def get_duration(prompt, image, duration):
|
139 |
+
return int(duration)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
+
@spaces.GPU(duration=get_duration)
|
142 |
+
def generate_image(prompt, image, duration):
|
143 |
return generate_image(prompt, image)
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
if __name__ == "__main__":
|
147 |
demo = gr.Interface(
|
148 |
+
fn=generate_image,
|
149 |
inputs=[
|
150 |
"text",
|
151 |
gr.Image(image_mode='RGBA', type="numpy"),
|