codermert commited on
Commit
a1538f9
·
verified ·
1 Parent(s): 8110484

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -23
app.py CHANGED
@@ -3,29 +3,36 @@ import torch
3
  from diffusers import AutoPipelineForText2Image
4
 
5
  def generate_image(prompt):
6
- # Pipeline'ı başlat
7
- pipeline = AutoPipelineForText2Image.from_pretrained(
8
- 'prithivMLmods/Canopus-LoRA-Flux-UltraRealism-2.0',
9
- torch_dtype=torch.float16
10
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- # LoRA modelini yükle
13
- pipeline.load_lora_weights(
14
- 'codermert/ezelll_flux',
15
- weight_name='flux_train_replicate.safetensors'
16
- )
17
 
18
- # Görsel oluştur
19
- image = pipeline(prompt).images[0]
20
- return image
21
-
22
- # Gradio arayüzü
23
- iface = gr.Interface(
24
- fn=generate_image,
25
- inputs=gr.Textbox(label="Prompt'unuzu girin (zehra kelimesini kullanmayı unutmayın)"),
26
- outputs=gr.Image(label="Oluşturulan Görsel"),
27
- title="Ezel Flux Görsel Oluşturucu",
28
- description="Bu model 'zehra' kelimesi ile en iyi sonucu verir."
29
- )
30
 
31
- iface.launch()
 
 
3
  from diffusers import AutoPipelineForText2Image
4
 
5
  def generate_image(prompt):
6
+ try:
7
+ # Pipeline'ı CPU modunda başlat (Space'de GPU yoksa)
8
+ pipeline = AutoPipelineForText2Image.from_pretrained(
9
+ 'prithivMLmods/Canopus-LoRA-Flux-UltraRealism-2.0',
10
+ torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32
11
+ ).to('cuda' if torch.cuda.is_available() else 'cpu')
12
+
13
+ # LoRA modelini yükle
14
+ pipeline.load_lora_weights(
15
+ 'codermert/ezelll_flux',
16
+ weight_name='flux_train_replicate.safetensors'
17
+ )
18
+
19
+ # Görsel oluştur
20
+ image = pipeline(prompt).images[0]
21
+ return image
22
+ except Exception as e:
23
+ return str(e)
24
+
25
+ # Gradio arayüzünü SSR modu kapalı olarak başlat
26
+ with gr.Blocks() as iface:
27
+ gr.Markdown("# Ezel Flux Görsel Oluşturucu")
28
+ gr.Markdown("Bu model 'zehra' kelimesi ile en iyi sonucu verir.")
29
 
30
+ with gr.Row():
31
+ text_input = gr.Textbox(label="Prompt'unuzu girin (zehra kelimesini kullanmayı unutmayın)")
32
+ image_output = gr.Image(label="Oluşturulan Görsel")
 
 
33
 
34
+ generate_btn = gr.Button("Görsel Oluştur")
35
+ generate_btn.click(fn=generate_image, inputs=[text_input], outputs=[image_output])
 
 
 
 
 
 
 
 
 
 
36
 
37
+ # SSR modunu kapatarak ve kuyruk sistemini etkinleştirerek başlat
38
+ iface.queue().launch(ssr_mode=False)