testt / app.py
codermert's picture
Update app.py
a1538f9 verified
raw
history blame
1.42 kB
import gradio as gr
import torch
from diffusers import AutoPipelineForText2Image
def generate_image(prompt):
try:
# Pipeline'ı CPU modunda başlat (Space'de GPU yoksa)
pipeline = AutoPipelineForText2Image.from_pretrained(
'prithivMLmods/Canopus-LoRA-Flux-UltraRealism-2.0',
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32
).to('cuda' if torch.cuda.is_available() else 'cpu')
# LoRA modelini yükle
pipeline.load_lora_weights(
'codermert/ezelll_flux',
weight_name='flux_train_replicate.safetensors'
)
# Görsel oluştur
image = pipeline(prompt).images[0]
return image
except Exception as e:
return str(e)
# Gradio arayüzünü SSR modu kapalı olarak başlat
with gr.Blocks() as iface:
gr.Markdown("# Ezel Flux Görsel Oluşturucu")
gr.Markdown("Bu model 'zehra' kelimesi ile en iyi sonucu verir.")
with gr.Row():
text_input = gr.Textbox(label="Prompt'unuzu girin (zehra kelimesini kullanmayı unutmayın)")
image_output = gr.Image(label="Oluşturulan Görsel")
generate_btn = gr.Button("Görsel Oluştur")
generate_btn.click(fn=generate_image, inputs=[text_input], outputs=[image_output])
# SSR modunu kapatarak ve kuyruk sistemini etkinleştirerek başlat
iface.queue().launch(ssr_mode=False)