1c1 commited on
Commit
e425bfb
·
verified ·
1 Parent(s): ee1a4d0

Create Python

Browse files
Files changed (1) hide show
  1. Python +52 -0
Python ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ MODEL_ID = "1c1/Hh" # Space’e yüklediğin modelin ID’si veya SD1.5 base
6
+
7
+ # Pipeline yükleme
8
+ pipe = StableDiffusionPipeline.from_pretrained(
9
+ MODEL_ID,
10
+ torch_dtype=torch.float16,
11
+ ).to("cuda")
12
+
13
+ # Sohbet geçmişi
14
+ history = []
15
+
16
+ def chat_and_generate(message, mode, size, turbo):
17
+ global history
18
+ # Bot cevabı
19
+ reply = f"Tamam! '{message}' için görsel üretebilirim."
20
+ history.append(("Kullanıcı: " + message, "Bot: " + reply))
21
+
22
+ # Görsel üretim
23
+ w, h = map(int, size.split("x"))
24
+ steps = 16 if turbo else 30
25
+
26
+ prompt = message
27
+ if mode == "Anime":
28
+ prompt += ", anime style, sharp lines, vibrant colors"
29
+ else:
30
+ prompt += ", ultra realistic, 8k, detailed textures"
31
+
32
+ image = pipe(prompt, num_inference_steps=steps, width=w, height=h).images[0]
33
+ return history, image
34
+
35
+ # Arayüz
36
+ sizes = ["512x512", "768x768", "1024x1024", "1536x1536", "4096x4096", "7680x4320"]
37
+
38
+ with gr.Blocks(title="ZImageAI – VisionPy") as demo:
39
+ gr.Markdown("<h1 style='text-align:center'>🚀 ZImageAI – VisionPy Ultra HD</h1>")
40
+
41
+ with gr.Row():
42
+ msg = gr.Textbox(label="Mesaj / Prompt", placeholder="örn: bir dağ manzarası, güneşli hava")
43
+ mode = gr.Radio(["Anime", "Gerçekçi"], value="Gerçekçi", label="Mod")
44
+ size = gr.Dropdown(sizes, value="1024x1024", label="Görsel Boyutu")
45
+ turbo = gr.Checkbox(label="⚡ 11s Turbo Mod", value=False)
46
+
47
+ chatbox = gr.Chatbot(label="Sohbet / Görsel")
48
+ btn = gr.Button("Gönder ve Üret")
49
+
50
+ btn.click(chat_and_generate, inputs=[msg, mode, size, turbo], outputs=[chatbox, chatbox])
51
+
52
+ demo.launch()