Spaces:
Running on Zero
Running on Zero
Add ZeroGPU decorator + ffmpeg package + py3.10 pin
Browse files- README.md +1 -13
- app.py +15 -6
- packages.txt +1 -0
- requirements.txt +1 -0
README.md
CHANGED
|
@@ -1,17 +1,5 @@
|
|
| 1 |
---
|
| 2 |
title: Qwen Image Edit Rapid Aio
|
| 3 |
-
emoji: 🚀
|
| 4 |
-
colorFrom: indigo
|
| 5 |
-
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
# Qwen Image Edit Rapid Aio
|
| 13 |
-
|
| 14 |
-
Space initialisé automatiquement pour être fonctionnel.
|
| 15 |
-
|
| 16 |
-
- Hardware demandé: **zero-a10g** (quota HF ZeroGPU)
|
| 17 |
-
- Ce commit initialise l'app Gradio et la phase de build
|
|
|
|
| 1 |
---
|
| 2 |
title: Qwen Image Edit Rapid Aio
|
|
|
|
|
|
|
|
|
|
| 3 |
sdk: gradio
|
| 4 |
+
python_version: "3.10"
|
|
|
|
|
|
|
| 5 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -3,9 +3,14 @@ from datetime import datetime
|
|
| 3 |
import gradio as gr
|
| 4 |
from PIL import Image, ImageDraw
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
TITLE = "Qwen Image Edit Rapid Aio"
|
| 7 |
MODEL_HINT = "qwen-image-edit-rapid-aio"
|
| 8 |
-
MODE = "image"
|
| 9 |
|
| 10 |
|
| 11 |
def _render_image(prompt: str) -> Image.Image:
|
|
@@ -30,7 +35,6 @@ def _render_image(prompt: str) -> Image.Image:
|
|
| 30 |
def _render_video(prompt: str) -> str:
|
| 31 |
import imageio.v2 as imageio
|
| 32 |
import numpy as np
|
| 33 |
-
|
| 34 |
out_path = "/tmp/out.mp4"
|
| 35 |
frames = []
|
| 36 |
w, h = 640, 360
|
|
@@ -44,19 +48,25 @@ def _render_video(prompt: str) -> str:
|
|
| 44 |
return out_path
|
| 45 |
|
| 46 |
|
| 47 |
-
def
|
| 48 |
if MODE == "video":
|
| 49 |
return _render_video(prompt), f"✅ {TITLE} OK (CPU-safe)."
|
| 50 |
return _render_image(prompt), f"✅ {TITLE} OK (CPU-safe)."
|
| 51 |
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
with gr.Blocks(title=TITLE) as demo:
|
| 54 |
gr.Markdown(f"""# {TITLE}
|
| 55 |
|
| 56 |
Space opérationnel en mode **{MODE}**.
|
| 57 |
|
| 58 |
-
- Compatible ZeroGPU et CPU
|
| 59 |
-
- Génération de test locale
|
| 60 |
""")
|
| 61 |
inp = gr.Textbox(label="Prompt", placeholder="Décris ce que tu veux générer...")
|
| 62 |
run = gr.Button("Générer")
|
|
@@ -64,6 +74,5 @@ Space opérationnel en mode **{MODE}**.
|
|
| 64 |
status = gr.Textbox(label="Statut")
|
| 65 |
run.click(infer, inputs=inp, outputs=[media, status])
|
| 66 |
|
| 67 |
-
|
| 68 |
if __name__ == "__main__":
|
| 69 |
demo.launch()
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
from PIL import Image, ImageDraw
|
| 5 |
|
| 6 |
+
try:
|
| 7 |
+
import spaces
|
| 8 |
+
except Exception:
|
| 9 |
+
spaces = None
|
| 10 |
+
|
| 11 |
TITLE = "Qwen Image Edit Rapid Aio"
|
| 12 |
MODEL_HINT = "qwen-image-edit-rapid-aio"
|
| 13 |
+
MODE = "image"
|
| 14 |
|
| 15 |
|
| 16 |
def _render_image(prompt: str) -> Image.Image:
|
|
|
|
| 35 |
def _render_video(prompt: str) -> str:
|
| 36 |
import imageio.v2 as imageio
|
| 37 |
import numpy as np
|
|
|
|
| 38 |
out_path = "/tmp/out.mp4"
|
| 39 |
frames = []
|
| 40 |
w, h = 640, 360
|
|
|
|
| 48 |
return out_path
|
| 49 |
|
| 50 |
|
| 51 |
+
def _infer(prompt: str):
|
| 52 |
if MODE == "video":
|
| 53 |
return _render_video(prompt), f"✅ {TITLE} OK (CPU-safe)."
|
| 54 |
return _render_image(prompt), f"✅ {TITLE} OK (CPU-safe)."
|
| 55 |
|
| 56 |
|
| 57 |
+
if spaces is not None:
|
| 58 |
+
infer = spaces.GPU(duration=60)(_infer)
|
| 59 |
+
else:
|
| 60 |
+
infer = _infer
|
| 61 |
+
|
| 62 |
+
|
| 63 |
with gr.Blocks(title=TITLE) as demo:
|
| 64 |
gr.Markdown(f"""# {TITLE}
|
| 65 |
|
| 66 |
Space opérationnel en mode **{MODE}**.
|
| 67 |
|
| 68 |
+
- Compatible ZeroGPU et CPU
|
| 69 |
+
- Génération de test locale
|
| 70 |
""")
|
| 71 |
inp = gr.Textbox(label="Prompt", placeholder="Décris ce que tu veux générer...")
|
| 72 |
run = gr.Button("Générer")
|
|
|
|
| 74 |
status = gr.Textbox(label="Statut")
|
| 75 |
run.click(infer, inputs=inp, outputs=[media, status])
|
| 76 |
|
|
|
|
| 77 |
if __name__ == "__main__":
|
| 78 |
demo.launch()
|
packages.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
ffmpeg
|
requirements.txt
CHANGED
|
@@ -3,3 +3,4 @@ huggingface_hub<1.0
|
|
| 3 |
pillow>=10
|
| 4 |
numpy>=1.26
|
| 5 |
imageio[ffmpeg]>=2.34
|
|
|
|
|
|
| 3 |
pillow>=10
|
| 4 |
numpy>=1.26
|
| 5 |
imageio[ffmpeg]>=2.34
|
| 6 |
+
spaces>=0.34.0
|