Update app.py
Browse files
app.py
CHANGED
@@ -7,11 +7,9 @@ import time
|
|
7 |
from PIL import Image
|
8 |
from deep_translator import GoogleTranslator
|
9 |
import json
|
10 |
-
|
11 |
from themes import IndonesiaTheme # Import custom IndonesiaTheme
|
12 |
|
13 |
# Project by Nymbo
|
14 |
-
|
15 |
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
|
16 |
API_TOKEN = os.getenv("HF_READ_TOKEN")
|
17 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
@@ -74,13 +72,67 @@ css = """
|
|
74 |
max-width: 800px;
|
75 |
margin-left: auto;
|
76 |
margin-right: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
"""
|
79 |
|
80 |
# Build the Gradio UI with Blocks
|
81 |
with gr.Blocks(theme=IndonesiaTheme(), css=css) as app:
|
82 |
-
# Add a title to the app
|
83 |
-
gr.HTML("<
|
|
|
|
|
|
|
84 |
|
85 |
# Container for all the UI elements
|
86 |
with gr.Column(elem_id="app-container"):
|
@@ -88,31 +140,31 @@ with gr.Blocks(theme=IndonesiaTheme(), css=css) as app:
|
|
88 |
with gr.Row():
|
89 |
with gr.Column(elem_id="prompt-container"):
|
90 |
with gr.Row():
|
91 |
-
text_prompt = gr.Textbox(label="Prompt", placeholder="
|
92 |
|
93 |
# Accordion for advanced settings
|
94 |
with gr.Row():
|
95 |
-
with gr.Accordion("
|
96 |
-
negative_prompt = gr.Textbox(label="
|
97 |
with gr.Row():
|
98 |
-
width = gr.Slider(label="
|
99 |
-
height = gr.Slider(label="
|
100 |
-
steps = gr.Slider(label="Sampling
|
101 |
-
cfg = gr.Slider(label="CFG
|
102 |
-
strength = gr.Slider(label="
|
103 |
-
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1)
|
104 |
-
method = gr.Radio(label="Sampling
|
105 |
|
106 |
# Add a button to trigger the image generation
|
107 |
with gr.Row():
|
108 |
-
text_button = gr.Button("
|
109 |
|
110 |
# Image output area to display the generated image
|
111 |
with gr.Row():
|
112 |
-
image_output = gr.Image(type="pil", label="
|
113 |
|
114 |
# Bind the button to the query function with the added width and height inputs
|
115 |
text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
|
116 |
|
117 |
# Launch the Gradio app
|
118 |
-
app.launch(show_api=False, share=False)
|
|
|
7 |
from PIL import Image
|
8 |
from deep_translator import GoogleTranslator
|
9 |
import json
|
|
|
10 |
from themes import IndonesiaTheme # Import custom IndonesiaTheme
|
11 |
|
12 |
# Project by Nymbo
|
|
|
13 |
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
|
14 |
API_TOKEN = os.getenv("HF_READ_TOKEN")
|
15 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
|
|
72 |
max-width: 800px;
|
73 |
margin-left: auto;
|
74 |
margin-right: auto;
|
75 |
+
padding: 20px;
|
76 |
+
background-color: #2b2b2b;
|
77 |
+
border-radius: 15px;
|
78 |
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
|
79 |
+
}
|
80 |
+
|
81 |
+
h1 {
|
82 |
+
font-size: 2.5rem;
|
83 |
+
text-align: center;
|
84 |
+
color: #ffa500;
|
85 |
+
margin-bottom: 10px;
|
86 |
+
font-weight: bold;
|
87 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
88 |
+
}
|
89 |
+
|
90 |
+
.description {
|
91 |
+
text-align: center;
|
92 |
+
font-size: 1.2rem;
|
93 |
+
color: #ffffff;
|
94 |
+
margin-bottom: 20px;
|
95 |
+
font-style: italic;
|
96 |
+
}
|
97 |
+
|
98 |
+
#gen-button {
|
99 |
+
background-color: #ff9800;
|
100 |
+
color: white;
|
101 |
+
font-weight: bold;
|
102 |
+
border-radius: 10px;
|
103 |
+
padding: 15px;
|
104 |
+
transition: background-color 0.3s ease;
|
105 |
+
}
|
106 |
+
|
107 |
+
#gen-button:hover {
|
108 |
+
background-color: #e67e22;
|
109 |
+
transform: scale(1.05);
|
110 |
+
}
|
111 |
+
|
112 |
+
#gallery {
|
113 |
+
border: 2px solid #ff9800;
|
114 |
+
border-radius: 15px;
|
115 |
+
}
|
116 |
+
|
117 |
+
#prompt-text-input, #negative-prompt-text-input {
|
118 |
+
background-color: #444444;
|
119 |
+
color: white;
|
120 |
+
border-radius: 8px;
|
121 |
+
border: 1px solid #ffa500;
|
122 |
+
}
|
123 |
+
|
124 |
+
label {
|
125 |
+
color: #ffffff;
|
126 |
}
|
127 |
"""
|
128 |
|
129 |
# Build the Gradio UI with Blocks
|
130 |
with gr.Blocks(theme=IndonesiaTheme(), css=css) as app:
|
131 |
+
# Add a title to the app with an emoji and large header
|
132 |
+
gr.HTML("<h1>π₯ Unlimited FLUX Schnell - V1.3 π₯</h1>")
|
133 |
+
|
134 |
+
# Description below the title in Indonesian
|
135 |
+
gr.HTML("<p class='description'>π Generator gambar AI berkualitas tinggi dengan kontrol penuh atas detail dan opsi lanjutan. Buat karya seni spektakuler dengan mudah! π¨</p>")
|
136 |
|
137 |
# Container for all the UI elements
|
138 |
with gr.Column(elem_id="app-container"):
|
|
|
140 |
with gr.Row():
|
141 |
with gr.Column(elem_id="prompt-container"):
|
142 |
with gr.Row():
|
143 |
+
text_prompt = gr.Textbox(label="π¨ Prompt", placeholder="Masukkan deskripsi gambar di sini", lines=2, elem_id="prompt-text-input")
|
144 |
|
145 |
# Accordion for advanced settings
|
146 |
with gr.Row():
|
147 |
+
with gr.Accordion("βοΈ Pengaturan Lanjutan", open=False):
|
148 |
+
negative_prompt = gr.Textbox(label="β Prompt Negatif", placeholder="Elemen yang tidak diinginkan dalam gambar", value="(deformed, distorted, disfigured)...", lines=3, elem_id="negative-prompt-text-input")
|
149 |
with gr.Row():
|
150 |
+
width = gr.Slider(label="Lebar", value=1024, minimum=64, maximum=1216, step=32)
|
151 |
+
height = gr.Slider(label="Tinggi", value=1024, minimum=64, maximum=1216, step=32)
|
152 |
+
steps = gr.Slider(label="Langkah Sampling", value=4, minimum=1, maximum=100, step=1)
|
153 |
+
cfg = gr.Slider(label="Skala CFG", value=7, minimum=1, maximum=20, step=1)
|
154 |
+
strength = gr.Slider(label="Kekuatan", value=0.7, minimum=0, maximum=1, step=0.001)
|
155 |
+
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1) # -1 for random
|
156 |
+
method = gr.Radio(label="Metode Sampling", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"])
|
157 |
|
158 |
# Add a button to trigger the image generation
|
159 |
with gr.Row():
|
160 |
+
text_button = gr.Button("π Buat Gambar", variant='primary', elem_id="gen-button")
|
161 |
|
162 |
# Image output area to display the generated image
|
163 |
with gr.Row():
|
164 |
+
image_output = gr.Image(type="pil", label="Hasil Gambar", elem_id="gallery")
|
165 |
|
166 |
# Bind the button to the query function with the added width and height inputs
|
167 |
text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
|
168 |
|
169 |
# Launch the Gradio app
|
170 |
+
app.launch(show_api=False, share=False)
|