John6666 commited on
Commit
2789ba4
·
verified ·
1 Parent(s): 420d105

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. civitai_to_hf.py +3 -3
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🤗
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: gradio
7
- sdk_version: 5.29.1
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 5.31.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
civitai_to_hf.py CHANGED
@@ -385,19 +385,19 @@ def get_civitai_json(dl_url: str, is_html: bool=False, image_baseurl: str="", ap
385
  url = base_url + model_id
386
  #url = base_url + str(dl_url.split("/")[-1])
387
  try:
388
- r = session.get(url, params=params, headers=headers, stream=True, timeout=(5.0, 15))
389
  if not r.ok: return default
390
  json = dict(r.json()).copy()
391
  html = ""
392
  image = ""
393
  if "modelId" in json.keys():
394
  url = f"https://civitai.com/models/{json['modelId']}"
395
- r = session.get(url, params=params, headers=headers, stream=True, timeout=(5.0, 15))
396
  if not r.ok: return json, html, image
397
  html = r.text
398
  if 'images' in json.keys() and len(json["images"]) != 0:
399
  url = json["images"][0]["url"]
400
- r = session.get(url, params=params, headers=headers, stream=True, timeout=(5.0, 15))
401
  if not r.ok: return json, html, image
402
  image_temp = str(Path(TEMP_DIR, "image" + Path(url.split("/")[-1]).suffix))
403
  image = str(Path(TEMP_DIR, Path(image_baseurl.split("/")[-1]).stem + ".png"))
 
385
  url = base_url + model_id
386
  #url = base_url + str(dl_url.split("/")[-1])
387
  try:
388
+ r = session.get(url, params=params, headers=headers, stream=True, timeout=(5.0, 60))
389
  if not r.ok: return default
390
  json = dict(r.json()).copy()
391
  html = ""
392
  image = ""
393
  if "modelId" in json.keys():
394
  url = f"https://civitai.com/models/{json['modelId']}"
395
+ r = session.get(url, params=params, headers=headers, stream=True, timeout=(5.0, 60))
396
  if not r.ok: return json, html, image
397
  html = r.text
398
  if 'images' in json.keys() and len(json["images"]) != 0:
399
  url = json["images"][0]["url"]
400
+ r = session.get(url, params=params, headers=headers, stream=True, timeout=(5.0, 60))
401
  if not r.ok: return json, html, image
402
  image_temp = str(Path(TEMP_DIR, "image" + Path(url.split("/")[-1]).suffix))
403
  image = str(Path(TEMP_DIR, Path(image_baseurl.split("/")[-1]).stem + ".png"))