Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,7 @@ from qwenimage.transformer_qwenimage import QwenImageTransformer2DModel
|
|
| 13 |
from qwenimage.qwen_fa3_processor import QwenDoubleStreamAttnProcessorFA3
|
| 14 |
import requests
|
| 15 |
import logging
|
|
|
|
| 16 |
|
| 17 |
# Set up logging to suppress print statements in UI
|
| 18 |
logging.basicConfig(level=logging.INFO, filename='qwen_image_editor.log', filemode='a')
|
|
@@ -68,9 +69,11 @@ scheduler_config = {
|
|
| 68 |
scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)
|
| 69 |
|
| 70 |
# Load the model pipeline
|
| 71 |
-
pipe = QwenImageEditPlusPipeline.from_pretrained(
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
pipe.load_lora_weights(
|
| 75 |
"lightx2v/Qwen-Image-Lightning",
|
| 76 |
weight_name="Qwen-Image-Lightning-4steps-V2.0.safetensors"
|
|
@@ -593,7 +596,18 @@ def create_demo():
|
|
| 593 |
|
| 594 |
return demo
|
| 595 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
if __name__ == "__main__":
|
| 597 |
logger.info(f"Gradio version: {gr.__version__}")
|
| 598 |
-
demo = create_demo()
|
| 599 |
demo.queue().launch(share=True)
|
|
|
|
| 13 |
from qwenimage.qwen_fa3_processor import QwenDoubleStreamAttnProcessorFA3
|
| 14 |
import requests
|
| 15 |
import logging
|
| 16 |
+
from fastapi import FastAPI, HTTPException
|
| 17 |
|
| 18 |
# Set up logging to suppress print statements in UI
|
| 19 |
logging.basicConfig(level=logging.INFO, filename='qwen_image_editor.log', filemode='a')
|
|
|
|
| 69 |
scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)
|
| 70 |
|
| 71 |
# Load the model pipeline
|
| 72 |
+
pipe = QwenImageEditPlusPipeline.from_pretrained(
|
| 73 |
+
"Qwen/Qwen-Image-Edit-2509",
|
| 74 |
+
scheduler=scheduler,
|
| 75 |
+
torch_dtype=dtype
|
| 76 |
+
).to(device)
|
| 77 |
pipe.load_lora_weights(
|
| 78 |
"lightx2v/Qwen-Image-Lightning",
|
| 79 |
weight_name="Qwen-Image-Lightning-4steps-V2.0.safetensors"
|
|
|
|
| 596 |
|
| 597 |
return demo
|
| 598 |
|
| 599 |
+
# --- FastAPI Setup for Path Restriction ---
|
| 600 |
+
app = FastAPI()
|
| 601 |
+
|
| 602 |
+
# Mount Gradio app at /spaceishere
|
| 603 |
+
demo = create_demo()
|
| 604 |
+
app.mount("/spaceishere", demo.app)
|
| 605 |
+
|
| 606 |
+
# Return 500 error for all other paths
|
| 607 |
+
@app.get("/{path:path}")
|
| 608 |
+
async def catch_all(path: str):
|
| 609 |
+
raise HTTPException(status_code=500, detail="Internal Server Error")
|
| 610 |
+
|
| 611 |
if __name__ == "__main__":
|
| 612 |
logger.info(f"Gradio version: {gr.__version__}")
|
|
|
|
| 613 |
demo.queue().launch(share=True)
|