Update app.py
Browse files
app.py
CHANGED
@@ -1,76 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
import os
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
# Inference Client'ı oluştur
|
8 |
-
client = InferenceClient(
|
9 |
-
provider="hf-inference",
|
10 |
-
token=HF_TOKEN,
|
11 |
-
)
|
12 |
|
13 |
-
def
|
14 |
-
|
15 |
-
|
16 |
-
prompt = "TOK, " + prompt
|
17 |
-
|
18 |
-
try:
|
19 |
-
# Görseli oluştur
|
20 |
-
image = client.text_to_image(
|
21 |
-
prompt,
|
22 |
-
model="black-forest-labs/FLUX.1-dev",
|
23 |
-
negative_prompt=negative_prompt
|
24 |
-
)
|
25 |
-
return image
|
26 |
-
except Exception as e:
|
27 |
-
return str(e)
|
28 |
|
29 |
# Gradio arayüzü
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
""
|
35 |
-
|
36 |
-
|
37 |
-
with gr.Column():
|
38 |
-
prompt = gr.Textbox(
|
39 |
-
label="Ne tür bir görsel istersin?",
|
40 |
-
placeholder="Örnek: A beautiful portrait photo in a city",
|
41 |
-
lines=3
|
42 |
-
)
|
43 |
-
negative_prompt = gr.Textbox(
|
44 |
-
label="İstemediğin özellikler",
|
45 |
-
value="blurry, bad quality, worst quality, jpeg artifacts",
|
46 |
-
lines=2
|
47 |
-
)
|
48 |
-
generate_btn = gr.Button("Görsel Oluştur 🎨")
|
49 |
-
|
50 |
-
with gr.Column():
|
51 |
-
output_image = gr.Image(label="İşte görselin!")
|
52 |
-
|
53 |
-
# Örnek promptlar
|
54 |
-
gr.Examples(
|
55 |
-
examples=[
|
56 |
-
["A striking woman lit with bi-color directional lighting poses",
|
57 |
-
"blurry, bad quality, worst quality, jpeg artifacts"],
|
58 |
-
["A beautiful portrait photo in a city",
|
59 |
-
"blurry, bad quality"],
|
60 |
-
],
|
61 |
-
inputs=[prompt, negative_prompt],
|
62 |
-
outputs=output_image,
|
63 |
-
fn=generate_image,
|
64 |
-
cache_examples=True,
|
65 |
-
)
|
66 |
-
|
67 |
-
# Butona tıklayınca çalışacak fonksiyon
|
68 |
-
generate_btn.click(
|
69 |
-
fn=generate_image,
|
70 |
-
inputs=[prompt, negative_prompt],
|
71 |
-
outputs=output_image
|
72 |
-
)
|
73 |
|
74 |
-
|
75 |
-
if __name__ == "__main__":
|
76 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
|
|
3 |
|
4 |
+
# Modelinizi yükleyin (örneğin, metin üretimi için)
|
5 |
+
model = pipeline("text-generation", model="codermert/ezelll_flux")
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
def generate_text(prompt):
|
8 |
+
output = model(prompt, max_length=100)
|
9 |
+
return output[0]["generated_text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Gradio arayüzü
|
12 |
+
demo = gr.Interface(
|
13 |
+
fn=generate_text,
|
14 |
+
inputs=gr.Textbox(lines=2, placeholder="Bir metin girin..."),
|
15 |
+
outputs="text",
|
16 |
+
title="ezelll_flux Model Demo",
|
17 |
+
description="Bu demo, codermert/ezelll_flux modelini kullanarak metin üretir."
|
18 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
demo.launch()
|
|
|
|