Spaces:
Configuration error
Configuration error
File size: 1,095 Bytes
1d0d1f3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
# بارگذاری مدل (qwen_3.5_4b_i8x)
pipe = StableDiffusionPipeline.from_ckpt(
"/path/to/On My iPhone ▸ Draw Things ▸ Models", # .ckpt
torch_dtype=torch.float32, # float16 CPU
use_safetensors=True
)
pipe = pipe.to("cpu") # CPU
def generate(prompt, negative_prompt="", steps=20, guidance=7.5):
image = pipe(
prompt,
negative_prompt=negative_prompt,
num_inference_steps=steps,
guidance_scale=guidance
).images[0]
return image
iface = gr.Interface(
fn=generate,
inputs=[
gr.Textbox(label="پرامپت"),
gr.Textbox(label="پرامپت منفی", value=""),
gr.Slider(5, 50, value=20, label="Steps"),
gr.Slider(1, 15, value=7.5, label="Guidance Scale")
],
outputs=gr.Image(label="نتیجه"),
title="AI Video/Image Generator محلی",
description="کاملاً آفلاین - مدل .ckpt"
)
iface.launch(server_name="127.0.0.1", server_port=7860, share=true) |