Spaces:
Running on Zero
Upload ba.txt
from fastapi import FastAPI
from fastapi.responses import FileResponse
from diffusers import StableDiffusionPipeline
import torch, uuid, os
app = FastAPI()
os.makedirs("generated_images", exist_ok=True)
Modeli yükle
pipe = StableDiffusionPipeline.from_pretrained(
"username/Z-Image-Auto", torch_dtype=torch.float16
)
pipe = pipe.to("cuda") # GPU varsa hızlanır
Örnek tüm kategoriler (dilediğin kadar ekleyebilirsin)
categories = [
"cat", "dog", "lion", "forest", "mountain", "river",
"robot", "spaceship", "cyberpunk city", "anime character",
"fantasy castle", "dragon", "car", "plane", "historical scene",
"3D render", "pixel art", "digital painting"
]
@app .get("/generate_all/")
def generate_all():
results = []
for cat in categories:
file_id = str(uuid.uuid4())
file_path = f"generated_images/{file_id}.png"
image = pipe(cat).images[0]
image.save(file_path)
results.append({
"category": cat,
"url": f"/image/{file_id}.png"
})
return results
@app .get("/image/{file_id}.png")
def get_image(file_id: str):
return FileResponse(f"generated_images/{file_id}.png")
🤖 Automated Message
This Pull Request has been automatically closed.
This Space is meant to be used through the Gradio interface, not via Pull Requests.
👉 To use this Space: Visit the Space directly and enter your input in the Gradio app.
This PR was closed because it contained no code changes (empty or image-only).