Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
def generate_image(prompt, num_inference_steps=50):
|
| 6 |
+
# Kendi modelinizi yükleyin
|
| 7 |
+
base_model = StableDiffusionPipeline.from_pretrained("codermert/mert_flux", torch_dtype=torch.float16)
|
| 8 |
+
base_model.to("cuda")
|
| 9 |
+
|
| 10 |
+
# Flux LoRA modelini yükleyin
|
| 11 |
+
lora_model_id = "lucataco/flux-dev-lora"
|
| 12 |
+
base_model.load_lora_weights(lora_model_id)
|
| 13 |
+
|
| 14 |
+
# Resmi oluşturun
|
| 15 |
+
image = base_model(prompt, num_inference_steps=num_inference_steps).images[0]
|
| 16 |
+
|
| 17 |
+
return image
|
| 18 |
+
|
| 19 |
+
iface = gr.Interface(
|
| 20 |
+
fn=generate_image,
|
| 21 |
+
inputs=[
|
| 22 |
+
gr.Textbox(label="Prompt"),
|
| 23 |
+
gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=50)
|
| 24 |
+
],
|
| 25 |
+
outputs=gr.Image(label="Generated Image"),
|
| 26 |
+
title="Mert Flux Image Generator",
|
| 27 |
+
description="Generate images using Mert Flux model and Flux LoRA"
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
iface.launch()
|