app.py
CHANGED
@@ -1,44 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
-
import torch
|
3 |
-
from PIL import Image
|
4 |
-
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
gr.load("models/radames/stable-diffusion-2-1-img2img").launch()
|
9 |
-
|
10 |
-
model_id = "stabilityai/stable-diffusion-2-1"
|
11 |
-
|
12 |
-
device = "cpu"
|
13 |
-
# DPM-Solver++ scheduler'ını kullan, torch_dtype belirtme
|
14 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id)
|
15 |
-
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
16 |
-
pipe = pipe.to(device)
|
17 |
|
18 |
-
def
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
29 |
|
30 |
-
|
31 |
-
fn=infer,
|
32 |
-
inputs=[
|
33 |
-
gr.Image(type="filepath", label="Raw Image. Must Be .png"), # Güncellenmiş kullanım
|
34 |
-
gr.Textbox(label='Prompt Input Text. 77 Token (Keyword or Symbol) Maximum'),
|
35 |
-
gr.Textbox(label='What you Do Not want the AI to generate.'),
|
36 |
-
gr.Slider(2, 15, value=7, label='Guidance Scale'),
|
37 |
-
gr.Slider(1, 25, value=10, step=1, label='Number of Iterations'),
|
38 |
-
gr.Slider(label="Seed", minimum=0, maximum=987654321987654321, step=1, randomize=True),
|
39 |
-
gr.Slider(label='Strength', minimum=0, maximum=1, step=.05, value=.5)
|
40 |
-
],
|
41 |
-
outputs=gr.Image(type="pil"),
|
42 |
-
title="Stable Diffusion 2.1 Image to Image Pipeline on CPU",
|
43 |
-
description="For more information on Stable Diffusion 2.1 see https://github.com/Stability-AI/stablediffusion"
|
44 |
-
).launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
+
# Modeli yükle
|
4 |
+
model = gr.load("models/radames/stable-diffusion-2-1-img2img")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
def my_custom_function(image, prompt):
|
7 |
+
# Modeli doğrudan çağır
|
8 |
+
output = model(image=image, prompt=prompt)
|
9 |
+
# Burada output üzerinde ek işlemler yapabilirsiniz
|
10 |
+
# Örneğin, çıktıyı yeniden boyutlandırma, filtreleme vb.
|
11 |
+
return output
|
12 |
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=my_custom_function,
|
15 |
+
inputs=[gr.Image(type="pil"), gr.Textbox()],
|
16 |
+
outputs=gr.Image(type="pil"),
|
17 |
+
title="My Custom Stable Diffusion img2img Interface",
|
18 |
+
description="This is a custom interface for Stable Diffusion img2img model with additional processing."
|
19 |
+
)
|
20 |
|
21 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|