Add FP16 conversion option and update UI description

#39
by spawn99 - opened
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -113,7 +113,10 @@ def process_model(model_id, q_method, oauth_token: gr.OAuthToken | None):
113
  with tempfile.TemporaryDirectory(dir="converted") as tmpdir:
114
  # The target dir must not exist
115
  mlx_path = os.path.join(tmpdir, "mlx")
116
- convert(model_id, mlx_path=mlx_path, quantize=True, q_bits=QUANT_PARAMS[q_method])
 
 
 
117
  print("Conversion done")
118
  upload_to_hub(path=mlx_path, upload_repo=upload_repo, hf_path=model_id, oauth_token=oauth_token)
119
  print("Upload done")
@@ -142,9 +145,9 @@ with gr.Blocks(css=css) as demo:
142
  )
143
 
144
  q_method = gr.Dropdown(
145
- ["Q2", "Q3", "Q4", "Q6", "Q8"],
146
- label="Quantization Method",
147
- info="MLX quantization type",
148
  value="Q4",
149
  filterable=False,
150
  visible=True
@@ -160,8 +163,8 @@ with gr.Blocks(css=css) as demo:
160
  gr.Markdown(label="output"),
161
  gr.Image(show_label=False),
162
  ],
163
- title="Create your own MLX Quants, blazingly fast ⚡!",
164
- description="The space takes an HF repo as an input, quantizes it and creates a Public/ Private repo containing the selected quant under your HF user namespace.",
165
  api_name=False
166
  )
167
 
 
113
  with tempfile.TemporaryDirectory(dir="converted") as tmpdir:
114
  # The target dir must not exist
115
  mlx_path = os.path.join(tmpdir, "mlx")
116
+ if q_method == "FP16":
117
+ convert(model_id, mlx_path=mlx_path, quantize=False, dtype="float16")
118
+ else:
119
+ convert(model_id, mlx_path=mlx_path, quantize=True, q_bits=QUANT_PARAMS[q_method])
120
  print("Conversion done")
121
  upload_to_hub(path=mlx_path, upload_repo=upload_repo, hf_path=model_id, oauth_token=oauth_token)
122
  print("Upload done")
 
145
  )
146
 
147
  q_method = gr.Dropdown(
148
+ ["FP16", "Q2", "Q3", "Q4", "Q6", "Q8"],
149
+ label="Conversion Method",
150
+ info="MLX conversion type (FP16 for float16, Q2–Q8 for quantized models)",
151
  value="Q4",
152
  filterable=False,
153
  visible=True
 
163
  gr.Markdown(label="output"),
164
  gr.Image(show_label=False),
165
  ],
166
+ title="Create your own MLX Models, blazingly fast ⚡!",
167
+ description="The space takes an HF repo as an input, converts it to MLX format (FP 16 or quantized), and creates a Public/Private repo under your HF user namespace.",
168
  api_name=False
169
  )
170