Update app.py
Browse files
app.py
CHANGED
@@ -231,13 +231,59 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
|
|
231 |
card.data.tags.append("matrixportal")
|
232 |
card.data.base_model = model_id
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
card.text = dedent(
|
235 |
f"""
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
239 |
"""
|
240 |
)
|
|
|
241 |
readme_path = Path(outdir)/"README.md"
|
242 |
card.save(readme_path)
|
243 |
|
|
|
231 |
card.data.tags.append("matrixportal")
|
232 |
card.data.base_model = model_id
|
233 |
|
234 |
+
def get_license_info(card):
|
235 |
+
"""Model kartından lisans bilgisini güvenle çeker"""
|
236 |
+
if not hasattr(card, 'data'):
|
237 |
+
return "Unknown"
|
238 |
+
|
239 |
+
# Lisans bilgisini alma (license veya model_license alanlarından)
|
240 |
+
license_info = getattr(card.data, 'license', getattr(card.data, 'model_license', 'Unknown'))
|
241 |
+
|
242 |
+
# Dictionary formatı kontrolü
|
243 |
+
if isinstance(license_info, dict):
|
244 |
+
license_info = license_info.get('name', 'Unknown')
|
245 |
+
|
246 |
+
return str(license_info).strip() or "Unknown"
|
247 |
+
|
248 |
+
def get_license_info(card):
|
249 |
+
"""Model kartından lisans bilgisini güvenle çeker"""
|
250 |
+
if not hasattr(card, 'data'):
|
251 |
+
return "Unknown"
|
252 |
+
|
253 |
+
# Lisans bilgisini alma (license veya model_license alanlarından)
|
254 |
+
license_info = getattr(card.data, 'license', getattr(card.data, 'model_license', 'Unknown'))
|
255 |
+
|
256 |
+
# Dictionary formatı kontrolü
|
257 |
+
if isinstance(license_info, dict):
|
258 |
+
license_info = license_info.get('name', 'Unknown')
|
259 |
+
|
260 |
+
return str(license_info).strip() or "Unknown"
|
261 |
+
|
262 |
+
def format_license_text(license_name):
|
263 |
+
"""Lisans adını linkli hale getirir"""
|
264 |
+
license_name = str(license_name).lower().replace(' ', '-')
|
265 |
+
license_links = {
|
266 |
+
'apache-2.0': '[Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)',
|
267 |
+
'mit': '[MIT](https://opensource.org/licenses/MIT)',
|
268 |
+
'llama3.2': '[Llama 3 Community License](https://llama.meta.com/llama3/license)',
|
269 |
+
'cc-by-nc-4.0': '[CC-BY-NC-4.0](https://creativecommons.org/licenses/by-nc/4.0/)',
|
270 |
+
'openrail': '[OpenRAIL](https://huggingface.co/spaces/CompVis/stable-diffusion-license)'
|
271 |
+
}
|
272 |
+
return license_links.get(license_name, license_name)
|
273 |
+
|
274 |
+
# Lisans bilgisini al ve formatla
|
275 |
+
license_info = get_license_info(card)
|
276 |
+
formatted_license = format_license_text(license_info)
|
277 |
+
|
278 |
card.text = dedent(
|
279 |
f"""
|
280 |
+
- **Base model:** [{model_id}](https://huggingface.co/{model_id})
|
281 |
+
- **License:** {formatted_license}
|
282 |
+
|
283 |
+
Quantized with llama.cpp using [all-gguf-same-where](https://huggingface.co/spaces/matrixportal/all-gguf-same-where)
|
284 |
"""
|
285 |
)
|
286 |
+
|
287 |
readme_path = Path(outdir)/"README.md"
|
288 |
card.save(readme_path)
|
289 |
|