Spaces:
Paused
Paused
Create model.safetensors
Browse files- model.safetensors +48 -0
model.safetensors
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
# --------------------------
|
| 6 |
+
# MODEL YÜKLEME
|
| 7 |
+
# --------------------------
|
| 8 |
+
# Module *hiçbir yere bağlı değildir*
|
| 9 |
+
# Kendi Space dosyan: /model.safetensors
|
| 10 |
+
|
| 11 |
+
pipe = StableDiffusionPipeline.from_single_file(
|
| 12 |
+
"model.safetensors",
|
| 13 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 14 |
+
safety_checker=None
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
if torch.cuda.is_available():
|
| 18 |
+
pipe = pipe.to("cuda")
|
| 19 |
+
|
| 20 |
+
# --------------------------
|
| 21 |
+
# GÖRSEL ÜRETİM FONKSİYONU
|
| 22 |
+
# --------------------------
|
| 23 |
+
def generate(prompt, width, height, steps):
|
| 24 |
+
image = pipe(
|
| 25 |
+
prompt,
|
| 26 |
+
num_inference_steps=steps,
|
| 27 |
+
width=width,
|
| 28 |
+
height=height
|
| 29 |
+
).images[0]
|
| 30 |
+
return image
|
| 31 |
+
|
| 32 |
+
# --------------------------
|
| 33 |
+
# GRADIO ARAYÜZÜ
|
| 34 |
+
# --------------------------
|
| 35 |
+
with gr.Blocks(theme="soft") as demo:
|
| 36 |
+
gr.Markdown("# 🎨 Kendi Modelinden Görsel Üreten Bot\nTamamen Bağımsız • Bağlantısız")
|
| 37 |
+
|
| 38 |
+
prompt = gr.Textbox(label="Prompt", placeholder="ör: futuristic city, ultra detailed")
|
| 39 |
+
width = gr.Slider(256, 2048, value=512, step=8, label="Genişlik")
|
| 40 |
+
height = gr.Slider(256, 2048, value=512, step=8, label="Yükseklik")
|
| 41 |
+
steps = gr.Slider(10, 80, value=30, step=1, label="Steps")
|
| 42 |
+
|
| 43 |
+
btn = gr.Button("Görsel Üret")
|
| 44 |
+
output = gr.Image(label="Üretilen Görsel")
|
| 45 |
+
|
| 46 |
+
btn.click(generate, inputs=[prompt, width, height, steps], outputs=output)
|
| 47 |
+
|
| 48 |
+
demo.launch()
|