codermert commited on
Commit
c3dc8bf
·
verified ·
1 Parent(s): 252ae64

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ # Hugging Face'den FLUX modelini yükle
6
+ model_id = "black-forest-labs/FLUX.1-dev"
7
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
8
+ pipe = pipe.to("cuda") # GPU üzerinde çalışmak için CUDA'yı kullan
9
+
10
+ # Kendi LoRA modelini FLUX ile birleştir
11
+ pipe.unet.load_attn_procs("codermert/tugce2-lora")
12
+
13
+ # Gradio için resim üretme fonksiyonu
14
+ def generate_image(prompt):
15
+ image = pipe(prompt).images[0]
16
+ return image
17
+
18
+ # Gradio arayüzü
19
+ interface = gr.Interface(
20
+ fn=generate_image,
21
+ inputs=gr.Textbox(label="Prompt", placeholder="Enter your prompt here"),
22
+ outputs=gr.Image(label="Generated Image")
23
+ )
24
+
25
+ # Uygulama başlatılır
26
+ if __name__ == "__main__":
27
+ interface.launch()
28
+