rootlocalghost commited on
Commit
62e6098
·
verified ·
1 Parent(s): f239fbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -7,8 +7,6 @@ import gradio as gr
7
  from huggingface_hub import HfApi, hf_hub_download
8
  from safetensors.torch import load_file, save_file
9
 
10
- # --- ARCHITECTURE PROFILES ---
11
- # Defines which sensitive layers must stay in BF16 during INT8 quantization to prevent precision collapse.
12
  ARCH_PROFILES = {
13
  "FLUX / Generic Rectified Flow": ["norm", "ln_", "embed", "time_in", "vector_in", "guidance_in", "txt_in", "img_in"],
14
  "Z-Image / DiT Core": ["t_embedder", "cap_embedder", "all_x_embedder", "all_final_layer", "rope_embedder", "embed_tokens", "norm", "ln_", "shared"],
@@ -122,7 +120,8 @@ def toggle_int8_warning(precision):
122
  return gr.update(visible=(precision == "INT8"))
123
 
124
  # --- GUI ---
125
- with gr.Blocks(theme=gr.themes.Base(primary_hue="blue", neutral_hue="slate")) as demo:
 
126
  gr.Markdown(
127
  """
128
  # ⚡ Universal Model Quantizer Hub
@@ -132,7 +131,6 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="blue", neutral_hue="slate")) as
132
  )
133
 
134
  with gr.Row():
135
- # LEFT COLUMN: Configuration
136
  with gr.Column(scale=5):
137
  with gr.Tabs():
138
 
@@ -183,28 +181,22 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="blue", neutral_hue="slate")) as
183
 
184
  start_btn = gr.Button("🚀 Start Cloud Quantization", variant="primary", size="lg")
185
 
186
- # RIGHT COLUMN: Logs
187
  with gr.Column(scale=4):
188
  output_log = gr.Textbox(
189
  label="Terminal Output",
190
  lines=24,
191
  interactive=False,
192
- max_lines=30,
193
- show_copy_button=True
194
  )
195
 
196
- # --- WIRING ---
197
- # Presets
198
  preset_flux.click(lambda: ("black-forest-labs/FLUX.2-klein-9B", "FLUX / Generic Rectified Flow"), outputs=[source_repo, arch_profile])
199
  preset_zimage.click(lambda: ("your-username/Z-Image-Turbo", "Z-Image / DiT Core"), outputs=[source_repo, arch_profile])
200
  preset_sd3.click(lambda: ("stabilityai/stable-diffusion-3.5-large", "Stable Diffusion (SDXL/SD3)"), outputs=[source_repo, arch_profile])
201
 
202
- # Dynamic Updates
203
  source_repo.change(fn=generate_target_repo, inputs=[source_repo, precision], outputs=[target_repo])
204
  precision.change(fn=generate_target_repo, inputs=[source_repo, precision], outputs=[target_repo])
205
  precision.change(fn=toggle_int8_warning, inputs=[precision], outputs=[int8_warning])
206
 
207
- # Execution
208
  start_btn.click(
209
  fn=convert_and_upload,
210
  inputs=[hf_token, source_repo, target_repo, precision, target_components, arch_profile],
@@ -212,4 +204,4 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="blue", neutral_hue="slate")) as
212
  )
213
 
214
  if __name__ == "__main__":
215
- demo.launch()
 
7
  from huggingface_hub import HfApi, hf_hub_download
8
  from safetensors.torch import load_file, save_file
9
 
 
 
10
  ARCH_PROFILES = {
11
  "FLUX / Generic Rectified Flow": ["norm", "ln_", "embed", "time_in", "vector_in", "guidance_in", "txt_in", "img_in"],
12
  "Z-Image / DiT Core": ["t_embedder", "cap_embedder", "all_x_embedder", "all_final_layer", "rope_embedder", "embed_tokens", "norm", "ln_", "shared"],
 
120
  return gr.update(visible=(precision == "INT8"))
121
 
122
  # --- GUI ---
123
+ # FIXED: Removed the theme argument from gr.Blocks()
124
+ with gr.Blocks() as demo:
125
  gr.Markdown(
126
  """
127
  # ⚡ Universal Model Quantizer Hub
 
131
  )
132
 
133
  with gr.Row():
 
134
  with gr.Column(scale=5):
135
  with gr.Tabs():
136
 
 
181
 
182
  start_btn = gr.Button("🚀 Start Cloud Quantization", variant="primary", size="lg")
183
 
 
184
  with gr.Column(scale=4):
185
  output_log = gr.Textbox(
186
  label="Terminal Output",
187
  lines=24,
188
  interactive=False,
189
+ max_lines=30
 
190
  )
191
 
 
 
192
  preset_flux.click(lambda: ("black-forest-labs/FLUX.2-klein-9B", "FLUX / Generic Rectified Flow"), outputs=[source_repo, arch_profile])
193
  preset_zimage.click(lambda: ("your-username/Z-Image-Turbo", "Z-Image / DiT Core"), outputs=[source_repo, arch_profile])
194
  preset_sd3.click(lambda: ("stabilityai/stable-diffusion-3.5-large", "Stable Diffusion (SDXL/SD3)"), outputs=[source_repo, arch_profile])
195
 
 
196
  source_repo.change(fn=generate_target_repo, inputs=[source_repo, precision], outputs=[target_repo])
197
  precision.change(fn=generate_target_repo, inputs=[source_repo, precision], outputs=[target_repo])
198
  precision.change(fn=toggle_int8_warning, inputs=[precision], outputs=[int8_warning])
199
 
 
200
  start_btn.click(
201
  fn=convert_and_upload,
202
  inputs=[hf_token, source_repo, target_repo, precision, target_components, arch_profile],
 
204
  )
205
 
206
  if __name__ == "__main__":
207
+ demo.launch(theme=gr.themes.Base(primary_hue="blue", neutral_hue="slate"))