Upload 2 files
Browse files- app.py +76 -0
- requirements.txt +11 -0
app.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import spaces
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
# ====================== DOWNLOAD MODELOV ======================
|
| 7 |
+
def download_models():
|
| 8 |
+
print("📥 Downloading required models... (first run may take time)")
|
| 9 |
+
|
| 10 |
+
# Qwen Image Edit models
|
| 11 |
+
hf_hub_download("Comfy-Org/Qwen-Image-Edit_ComfyUI",
|
| 12 |
+
"split_files/diffusion_models/qwen_image_edit_2509_fp8_e4m3fn.safetensors",
|
| 13 |
+
local_dir="models/diffusion_models", force_download=False)
|
| 14 |
+
|
| 15 |
+
hf_hub_download("Comfy-Org/Qwen-Image_ComfyUI",
|
| 16 |
+
"split_files/vae/qwen_image_vae.safetensors",
|
| 17 |
+
local_dir="models/vae", force_download=False)
|
| 18 |
+
|
| 19 |
+
hf_hub_download("Comfy-Org/Qwen-Image_ComfyUI",
|
| 20 |
+
"split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors",
|
| 21 |
+
local_dir="models/text_encoders", force_download=False)
|
| 22 |
+
|
| 23 |
+
hf_hub_download("lightx2v/Qwen-Image-Lightning",
|
| 24 |
+
"Qwen-Image-Edit-2509/Qwen-Image-Edit-2509-Lightning-4steps-V1.0-bf16.safetensors",
|
| 25 |
+
local_dir="models/loras", force_download=False)
|
| 26 |
+
|
| 27 |
+
print("✅ Models ready!")
|
| 28 |
+
|
| 29 |
+
download_models()
|
| 30 |
+
|
| 31 |
+
# ====================== GENERATE FUNCTION ======================
|
| 32 |
+
@spaces.GPU(duration=180)
|
| 33 |
+
def generate(prompt_image, prompt_video, bedroom_image, woman_image):
|
| 34 |
+
if bedroom_image is None or woman_image is None:
|
| 35 |
+
return None, None, "❌ Naloži obe sliki!"
|
| 36 |
+
|
| 37 |
+
status = "🔄 Processing...\n1. Qwen Image Edit\n2. Wan2.2 Image to Video"
|
| 38 |
+
# Tukaj bo kasneje prišla polna ComfyUI logika
|
| 39 |
+
# Za zdaj placeholder
|
| 40 |
+
|
| 41 |
+
return None, None, status + "\n\n(Full execution coming soon)"
|
| 42 |
+
|
| 43 |
+
# ====================== GRADIO UI ======================
|
| 44 |
+
with gr.Blocks(title="Bedroom → Video", theme=gr.themes.Soft()) as demo:
|
| 45 |
+
gr.Markdown("# 🛏️ Bedroom Mix + Wan2.2 Video Generator")
|
| 46 |
+
|
| 47 |
+
with gr.Row():
|
| 48 |
+
with gr.Column():
|
| 49 |
+
prompt_image = gr.Textbox(
|
| 50 |
+
label="Prompt za urejanje slike (Qwen)",
|
| 51 |
+
lines=4,
|
| 52 |
+
value="Take the bedroom from image 1 and naturally integrate the woman from image 2 on the bed. Realistic proportions, good lighting, intimate atmosphere."
|
| 53 |
+
)
|
| 54 |
+
prompt_video = gr.Textbox(
|
| 55 |
+
label="Prompt za video (Wan2.2)",
|
| 56 |
+
lines=4,
|
| 57 |
+
value="smooth cinematic motion, realistic physics, intimate scene, high detail, 8k"
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
with gr.Row():
|
| 61 |
+
img1 = gr.Image(label="Bedroom Image", type="filepath")
|
| 62 |
+
img2 = gr.Image(label="Woman Image", type="filepath")
|
| 63 |
+
|
| 64 |
+
btn = gr.Button("🚀 Generate", variant="primary", size="large")
|
| 65 |
+
|
| 66 |
+
with gr.Column():
|
| 67 |
+
out_img = gr.Image(label="Generated Image")
|
| 68 |
+
out_video = gr.Video(label="Generated Video")
|
| 69 |
+
status = gr.Textbox(label="Status", interactive=False)
|
| 70 |
+
|
| 71 |
+
btn.click(generate,
|
| 72 |
+
inputs=[prompt_image, prompt_video, img1, img2],
|
| 73 |
+
outputs=[out_img, out_video, status])
|
| 74 |
+
|
| 75 |
+
if __name__ == "__main__":
|
| 76 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
requirements.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=5.0.0
|
| 2 |
+
spaces>=0.30.0
|
| 3 |
+
huggingface_hub>=0.25.0
|
| 4 |
+
Pillow
|
| 5 |
+
numpy
|
| 6 |
+
torch
|
| 7 |
+
torchvision
|
| 8 |
+
torchaudio
|
| 9 |
+
opencv-python-headless
|
| 10 |
+
imageio
|
| 11 |
+
imageio-ffmpeg
|