Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import gradio as gr
|
|
| 3 |
import numpy as np
|
| 4 |
import random
|
| 5 |
from huggingface_hub import AsyncInferenceClient
|
| 6 |
-
from translatepy import Translator
|
| 7 |
from gradio_client import Client, handle_file
|
| 8 |
from PIL import Image
|
| 9 |
from huggingface_hub import login
|
|
@@ -21,7 +21,7 @@ for lora in loras:
|
|
| 21 |
|
| 22 |
# Function to enable LoRA if selected
|
| 23 |
def enable_lora(lora_add, basemodel):
|
| 24 |
-
print(f"[-]
|
| 25 |
return basemodel if not lora_add else lora_add
|
| 26 |
|
| 27 |
def generate_character_description(character_prompt):
|
|
@@ -60,7 +60,7 @@ async def generate_image(prompt, model, lora_word, width, height, scales, steps,
|
|
| 60 |
seed = int(seed)
|
| 61 |
|
| 62 |
print(f"[-] Menerjemahkan prompt: {prompt}")
|
| 63 |
-
text = generate_character_description(str(Translator().translate(prompt, 'English'))) + "," + lora_word
|
| 64 |
|
| 65 |
print(f"[-] Generating image with prompt: {text}, model: {model}")
|
| 66 |
client = AsyncInferenceClient()
|
|
@@ -119,7 +119,7 @@ async def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_fac
|
|
| 119 |
print(f"[-] Proses upscaling selesai. Gambar tersimpan di: {upscale_image_path}")
|
| 120 |
return [image_path, upscale_image_path] # Return both images
|
| 121 |
else:
|
| 122 |
-
print("[-] Upscaling
|
| 123 |
|
| 124 |
return [image_path]
|
| 125 |
|
|
@@ -169,8 +169,8 @@ with gr.Blocks(css=css, theme=IndonesiaTheme()) as WallpaperFluxMaker:
|
|
| 169 |
# Column 1: Input prompt, LoRA, and base model
|
| 170 |
with gr.Column(scale=1, elem_id="col-left"):
|
| 171 |
prompt = gr.Textbox(
|
| 172 |
-
label="π
|
| 173 |
-
placeholder="
|
| 174 |
elem_id="textbox-prompt"
|
| 175 |
)
|
| 176 |
|
|
@@ -190,7 +190,7 @@ with gr.Blocks(css=css, theme=IndonesiaTheme()) as WallpaperFluxMaker:
|
|
| 190 |
)
|
| 191 |
|
| 192 |
lora_model_choice = gr.Dropdown(
|
| 193 |
-
label="π¨ select LoRA",
|
| 194 |
choices=[
|
| 195 |
"Shakker-Labs/FLUX.1-dev-LoRA-add-details",
|
| 196 |
"XLabs-AI/flux-RealismLora",
|
|
@@ -200,21 +200,21 @@ with gr.Blocks(css=css, theme=IndonesiaTheme()) as WallpaperFluxMaker:
|
|
| 200 |
value="XLabs-AI/flux-RealismLora"
|
| 201 |
)
|
| 202 |
|
| 203 |
-
process_lora =
|
| 204 |
-
process_upscale = gr.Checkbox(label="π
|
| 205 |
-
upscale_factor = gr.Radio(label="π
|
| 206 |
|
| 207 |
# Column 2: Advanced options (always open)
|
| 208 |
with gr.Column(scale=1, elem_id="col-right"):
|
| 209 |
-
with gr.Accordion(label="βοΈ
|
| 210 |
-
width = gr.Slider(label="
|
| 211 |
-
height = gr.Slider(label="
|
| 212 |
-
scales = gr.Slider(label="
|
| 213 |
-
steps = gr.Slider(label="
|
| 214 |
seed = gr.Number(label="Seed", value=-1)
|
| 215 |
|
| 216 |
# Button to generate image
|
| 217 |
-
btn = gr.Button("π
|
| 218 |
|
| 219 |
# Running the `gen` function when "Generate" button is pressed
|
| 220 |
btn.click(fn=gen, inputs=[
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
import random
|
| 5 |
from huggingface_hub import AsyncInferenceClient
|
| 6 |
+
#from translatepy import Translator
|
| 7 |
from gradio_client import Client, handle_file
|
| 8 |
from PIL import Image
|
| 9 |
from huggingface_hub import login
|
|
|
|
| 21 |
|
| 22 |
# Function to enable LoRA if selected
|
| 23 |
def enable_lora(lora_add, basemodel):
|
| 24 |
+
print(f"[-] Determining model: LoRA {'enabled' if lora_add else 'disabled'}, base model: {basemodel}")
|
| 25 |
return basemodel if not lora_add else lora_add
|
| 26 |
|
| 27 |
def generate_character_description(character_prompt):
|
|
|
|
| 60 |
seed = int(seed)
|
| 61 |
|
| 62 |
print(f"[-] Menerjemahkan prompt: {prompt}")
|
| 63 |
+
#text = generate_character_description(str(Translator().translate(prompt, 'English'))) + "," + lora_word
|
| 64 |
|
| 65 |
print(f"[-] Generating image with prompt: {text}, model: {model}")
|
| 66 |
client = AsyncInferenceClient()
|
|
|
|
| 119 |
print(f"[-] Proses upscaling selesai. Gambar tersimpan di: {upscale_image_path}")
|
| 120 |
return [image_path, upscale_image_path] # Return both images
|
| 121 |
else:
|
| 122 |
+
print("[-] Upscaling process, select the factor.")
|
| 123 |
|
| 124 |
return [image_path]
|
| 125 |
|
|
|
|
| 169 |
# Column 1: Input prompt, LoRA, and base model
|
| 170 |
with gr.Column(scale=1, elem_id="col-left"):
|
| 171 |
prompt = gr.Textbox(
|
| 172 |
+
label="π Image Description",
|
| 173 |
+
placeholder="Write your prompt in any language, and it will be automatically translated into English.",
|
| 174 |
elem_id="textbox-prompt"
|
| 175 |
)
|
| 176 |
|
|
|
|
| 190 |
)
|
| 191 |
|
| 192 |
lora_model_choice = gr.Dropdown(
|
| 193 |
+
label="π¨ select a LoRA",
|
| 194 |
choices=[
|
| 195 |
"Shakker-Labs/FLUX.1-dev-LoRA-add-details",
|
| 196 |
"XLabs-AI/flux-RealismLora",
|
|
|
|
| 200 |
value="XLabs-AI/flux-RealismLora"
|
| 201 |
)
|
| 202 |
|
| 203 |
+
process_lora =gr.Checkbox(label="π¨ Use LoRA")
|
| 204 |
+
process_upscale = gr.Checkbox(label="π Upscale resolution")
|
| 205 |
+
upscale_factor = gr.Radio(label="π Upscale factor", choices=[2, 4, 8], value=2)
|
| 206 |
|
| 207 |
# Column 2: Advanced options (always open)
|
| 208 |
with gr.Column(scale=1, elem_id="col-right"):
|
| 209 |
+
with gr.Accordion(label="βοΈ Settings", open=True):
|
| 210 |
+
width = gr.Slider(label="Width", minimum=512, maximum=1280, step=8, value=1280)
|
| 211 |
+
height = gr.Slider(label="Height", minimum=512, maximum=1280, step=8, value=768)
|
| 212 |
+
scales = gr.Slider(label="Scale", minimum=1, maximum=20, step=1, value=8)
|
| 213 |
+
steps = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=8)
|
| 214 |
seed = gr.Number(label="Seed", value=-1)
|
| 215 |
|
| 216 |
# Button to generate image
|
| 217 |
+
btn = gr.Button("π Bombs away!", elem_id="generate-btn")
|
| 218 |
|
| 219 |
# Running the `gen` function when "Generate" button is pressed
|
| 220 |
btn.click(fn=gen, inputs=[
|