K00B404 commited on
Commit
6b3081a
ยท
verified ยท
1 Parent(s): 10fca1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
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"[-] Menentukan model: LoRA {'diaktifkan' if lora_add else 'tidak diaktifkan'}, model dasar: {basemodel}")
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 gagal, jalur gambar upscale tidak ditemukan.")
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="๐Ÿ“œ Deskripsi Gambar",
173
- placeholder="Tuliskan prompt Anda dalam bahasa apapun, yang akan langsung diterjemahkan ke bahasa Inggris.",
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 = gr.Checkbox(label="๐ŸŽจ Aktifkan LoRA")
204
- process_upscale = gr.Checkbox(label="๐Ÿ” Aktifkan Peningkatan Resolusi")
205
- upscale_factor = gr.Radio(label="๐Ÿ” Faktor Peningkatan Resolusi", 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="โš™๏ธ Opsi Lanjutan", open=True):
210
- width = gr.Slider(label="Lebar", minimum=512, maximum=1280, step=8, value=1280)
211
- height = gr.Slider(label="Tinggi", minimum=512, maximum=1280, step=8, value=768)
212
- scales = gr.Slider(label="Skala", minimum=1, maximum=20, step=1, value=8)
213
- steps = gr.Slider(label="Langkah", 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("๐Ÿš€ Buat Gambar", elem_id="generate-btn")
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=[