codermert commited on
Commit
7ab00ee
·
verified ·
1 Parent(s): b028afc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -27
app.py CHANGED
@@ -1,38 +1,29 @@
1
  import gradio as gr
2
  import torch
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)
 
1
  import gradio as gr
2
  import torch
3
+ from diffusers import StableDiffusionPipeline
4
 
5
  def generate_image(prompt):
6
  try:
7
+ # Model yükleme
8
+ model_id = "runwayml/stable-diffusion-v1-5"
9
+ pipe = StableDiffusionPipeline.from_pretrained(
10
+ model_id,
11
+ torch_dtype=torch.float32
12
+ ).to('cpu')
13
 
14
+ # Görsel oluşturma
15
+ image = pipe(prompt).images[0]
 
 
 
 
 
 
16
  return image
17
  except Exception as e:
18
  return str(e)
19
 
20
+ # Gradio arayüzü
21
+ demo = gr.Interface(
22
+ fn=generate_image,
23
+ inputs=gr.Textbox(label="Prompt'unuzu girin"),
24
+ outputs=gr.Image(label="Oluşturulan Görsel"),
25
+ title="Görsel Oluşturucu",
26
+ description="Bir prompt girin ve görsel oluşturun"
27
+ )
 
 
 
28
 
29
+ demo.launch(debug=True, share=False)