K00B404 commited on
Commit
43a8be6
ยท
verified ยท
1 Parent(s): 5459c95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -30
app.py CHANGED
@@ -44,7 +44,12 @@ def generate_character_description(character_prompt, system_message = """
44
  return result
45
  except Exception as e:
46
  return f"Error generating description: {str(e)}"
47
-
 
 
 
 
 
48
  # Function to generate image
49
  async def generate_image(prompt, model, lora_word, width, height, scales, steps, seed):
50
  try:
@@ -53,7 +58,7 @@ async def generate_image(prompt, model, lora_word, width, height, scales, steps,
53
  seed = int(seed)
54
 
55
  print(f"[-] Menerjemahkan prompt: {prompt}")
56
- #text = generate_character_description(str(Translator().translate(prompt, 'English'))) + "," + lora_word
57
 
58
  print(f"[-] Generating image with prompt: {text}, model: {model}")
59
  client = AsyncInferenceClient()
@@ -66,18 +71,18 @@ async def generate_image(prompt, model, lora_word, width, height, scales, steps,
66
  # Function to upscale image
67
  def get_upscale_finegrain(prompt, img_path, upscale_factor):
68
  try:
69
- print(f"[-] Processing with Factor {upscale_factor} for Image {img_path}")
70
  client = Client("finegrain/finegrain-image-enhancer", hf_token=HF_TOKEN_UPSCALER)
71
  result = client.predict(
72
  input_image=handle_file(img_path),
73
  prompt=prompt,
74
  negative_prompt="worst quality, low quality, normal quality",
75
  upscale_factor=upscale_factor,
76
- controlnet_scale=0.7,
77
  controlnet_decay=1,
78
  condition_scale=6,
79
- denoise_strength=0.33,
80
- num_inference_steps=20,
81
  solver="DDIM",
82
  api_name="/process"
83
  )
@@ -112,7 +117,7 @@ async def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_fac
112
  print(f"[-] Proses upscaling selesai. Gambar tersimpan di: {upscale_image_path}")
113
  return [image_path, upscale_image_path] # Return both images
114
  else:
115
- print("[-] Upscaling process, select the factor.")
116
 
117
  return [image_path]
118
 
@@ -162,52 +167,49 @@ with gr.Blocks(css=css, theme=IndonesiaTheme()) as WallpaperFluxMaker:
162
  # Column 1: Input prompt, LoRA, and base model
163
  with gr.Column(scale=1, elem_id="col-left"):
164
  prompt = gr.Textbox(
165
- label="๐Ÿ“œ Image Description",
166
- placeholder="Write your prompt in any language, and it will be automatically translated into English.",
167
  elem_id="textbox-prompt"
168
  )
169
 
170
  basemodel_choice = gr.Dropdown(
171
- label="๐Ÿ–ผ๏ธ Select a Model",
172
  choices=[
173
- "black-forest-labs/FLUX.1-schnell",
174
- "black-forest-labs/FLUX.1-dev",
175
- "black-forest-labs/FLUX.1-merged",
176
- "dataautogpt3/FLUX-SyntheticAnime",
177
- "Shakker-Labs/FLUX.1-dev-LoRA-AntiBlur"
178
  "Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro",
179
  "Shakker-Labs/FLUX.1-dev-LoRA-add-details",
180
- "city96/FLUX.1-schnell-gguf"
181
  ],
182
  value="black-forest-labs/FLUX.1-schnell"
183
  )
184
 
185
  lora_model_choice = gr.Dropdown(
186
- label="๐ŸŽจ select a LoRA",
187
  choices=[
188
  "Shakker-Labs/FLUX.1-dev-LoRA-add-details",
189
  "XLabs-AI/flux-RealismLora",
190
- "enhanceaiteam/Flux-uncensored",
191
- "Keltezaa/female-masturbation-fingering"
192
- ]+loaded_loras,
193
  value="XLabs-AI/flux-RealismLora"
194
  )
195
 
196
- process_lora =gr.Checkbox(label="๐ŸŽจ Use LoRA")
197
- process_upscale = gr.Checkbox(label="๐Ÿ” Upscale resolution")
198
- upscale_factor = gr.Radio(label="๐Ÿ” Upscale factor", choices=[2, 4, 8], value=2)
199
 
200
  # Column 2: Advanced options (always open)
201
  with gr.Column(scale=1, elem_id="col-right"):
202
- with gr.Accordion(label="โš™๏ธ Settings", open=True):
203
- width = gr.Slider(label="Width", minimum=512, maximum=1280, step=8, value=1280)
204
- height = gr.Slider(label="Height", minimum=512, maximum=1280, step=8, value=768)
205
- scales = gr.Slider(label="Scale", minimum=1, maximum=20, step=1, value=8)
206
- steps = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=8)
207
  seed = gr.Number(label="Seed", value=-1)
208
 
209
  # Button to generate image
210
- btn = gr.Button("๐Ÿš€ Bombs away!", elem_id="generate-btn")
211
 
212
  # Running the `gen` function when "Generate" button is pressed
213
  btn.click(fn=gen, inputs=[
@@ -215,4 +217,4 @@ with gr.Blocks(css=css, theme=IndonesiaTheme()) as WallpaperFluxMaker:
215
  ], outputs=output_res)
216
 
217
  # Launching the Gradio app
218
- WallpaperFluxMaker.queue(api_open=False).launch(show_api=True)
 
44
  return result
45
  except Exception as e:
46
  return f"Error generating description: {str(e)}"
47
+
48
+ # Function to enable LoRA if selected
49
+ def enable_lora(lora_add, basemodel):
50
+ print(f"[-] Menentukan model: LoRA {'diaktifkan' if lora_add else 'tidak diaktifkan'}, model dasar: {basemodel}")
51
+ return basemodel if not lora_add else lora_add
52
+
53
  # Function to generate image
54
  async def generate_image(prompt, model, lora_word, width, height, scales, steps, seed):
55
  try:
 
58
  seed = int(seed)
59
 
60
  print(f"[-] Menerjemahkan prompt: {prompt}")
61
+ text = str(Translator().translate(prompt, 'English')) + "," + lora_word
62
 
63
  print(f"[-] Generating image with prompt: {text}, model: {model}")
64
  client = AsyncInferenceClient()
 
71
  # Function to upscale image
72
  def get_upscale_finegrain(prompt, img_path, upscale_factor):
73
  try:
74
+ print(f"[-] Memulai proses upscaling dengan faktor {upscale_factor} untuk gambar {img_path}")
75
  client = Client("finegrain/finegrain-image-enhancer", hf_token=HF_TOKEN_UPSCALER)
76
  result = client.predict(
77
  input_image=handle_file(img_path),
78
  prompt=prompt,
79
  negative_prompt="worst quality, low quality, normal quality",
80
  upscale_factor=upscale_factor,
81
+ controlnet_scale=0.6,
82
  controlnet_decay=1,
83
  condition_scale=6,
84
+ denoise_strength=0.35,
85
+ num_inference_steps=18,
86
  solver="DDIM",
87
  api_name="/process"
88
  )
 
117
  print(f"[-] Proses upscaling selesai. Gambar tersimpan di: {upscale_image_path}")
118
  return [image_path, upscale_image_path] # Return both images
119
  else:
120
+ print("[-] Upscaling gagal, jalur gambar upscale tidak ditemukan.")
121
 
122
  return [image_path]
123
 
 
167
  # Column 1: Input prompt, LoRA, and base model
168
  with gr.Column(scale=1, elem_id="col-left"):
169
  prompt = gr.Textbox(
170
+ label="๐Ÿ“œ Deskripsi Gambar",
171
+ placeholder="Tuliskan prompt Anda dalam bahasa apapun, yang akan langsung diterjemahkan ke bahasa Inggris.",
172
  elem_id="textbox-prompt"
173
  )
174
 
175
  basemodel_choice = gr.Dropdown(
176
+ label="๐Ÿ–ผ๏ธ Pilih Model",
177
  choices=[
178
+ "black-forest-labs/FLUX.1-schnell",
179
+ "black-forest-labs/FLUX.1-DEV",
180
+ "enhanceaiteam/Flux-uncensored",
 
 
181
  "Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro",
182
  "Shakker-Labs/FLUX.1-dev-LoRA-add-details",
183
+ "city96/FLUX.1-dev-gguf"
184
  ],
185
  value="black-forest-labs/FLUX.1-schnell"
186
  )
187
 
188
  lora_model_choice = gr.Dropdown(
189
+ label="๐ŸŽจ Pilih LoRA",
190
  choices=[
191
  "Shakker-Labs/FLUX.1-dev-LoRA-add-details",
192
  "XLabs-AI/flux-RealismLora",
193
+ "enhanceaiteam/Flux-uncensored"
194
+ ],
 
195
  value="XLabs-AI/flux-RealismLora"
196
  )
197
 
198
+ process_lora = gr.Checkbox(label="๐ŸŽจ Aktifkan LoRA")
199
+ process_upscale = gr.Checkbox(label="๐Ÿ” Aktifkan Peningkatan Resolusi")
200
+ upscale_factor = gr.Radio(label="๐Ÿ” Faktor Peningkatan Resolusi", choices=[2, 4, 8], value=2)
201
 
202
  # Column 2: Advanced options (always open)
203
  with gr.Column(scale=1, elem_id="col-right"):
204
+ with gr.Accordion(label="โš™๏ธ Opsi Lanjutan", open=True):
205
+ width = gr.Slider(label="Lebar", minimum=512, maximum=1280, step=8, value=1280)
206
+ height = gr.Slider(label="Tinggi", minimum=512, maximum=1280, step=8, value=768)
207
+ scales = gr.Slider(label="Skala", minimum=1, maximum=20, step=1, value=8)
208
+ steps = gr.Slider(label="Langkah", minimum=1, maximum=100, step=1, value=8)
209
  seed = gr.Number(label="Seed", value=-1)
210
 
211
  # Button to generate image
212
+ btn = gr.Button("๐Ÿš€ Buat Gambar", elem_id="generate-btn")
213
 
214
  # Running the `gen` function when "Generate" button is pressed
215
  btn.click(fn=gen, inputs=[
 
217
  ], outputs=output_res)
218
 
219
  # Launching the Gradio app
220
+ WallpaperFluxMaker.queue(api_open=False).launch(show_api=False)