NagisaNao commited on
Commit
37eccea
·
verified ·
1 Parent(s): b4dbd33
files_cells/notebooks/en/auto-cleaner_en.ipynb CHANGED
@@ -28,7 +28,7 @@
28
  "\n",
29
  "# ================= DETECT ENV =================\n",
30
  "def detect_environment():\n",
31
- " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
32
  " environments = {\n",
33
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
34
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
 
28
  "\n",
29
  "# ================= DETECT ENV =================\n",
30
  "def detect_environment():\n",
31
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
32
  " environments = {\n",
33
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
34
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
files_cells/notebooks/en/downloading_en.ipynb CHANGED
@@ -27,7 +27,7 @@
27
  "\n",
28
  "# ================= DETECT ENV =================\n",
29
  "def detect_environment():\n",
30
- " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
31
  " environments = {\n",
32
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
33
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
@@ -338,18 +338,18 @@
338
  "\n",
339
  "''' Get Image Preview | CivitAi '''\n",
340
  "\n",
341
- "def get_data_from_api(model_id, api_key): # get model data\n",
342
- " base_url = f\"https://civitai.com/api/v1/model-versions/{model_id}\"\n",
343
  " headers = {\"Content-Type\": \"application/json\"}\n",
344
  " try:\n",
345
- " response = requests.get(base_url, headers=headers)\n",
346
  " if response.status_code == 200:\n",
347
  " return response.json()\n",
348
  " except requests.exceptions.RequestException as e:\n",
349
  " print(f\"An error occurred: {e}\")\n",
350
  " return None\n",
351
  "\n",
352
- "def extract_model_info(data, url, supported_types):\n",
353
  " if 'type=' in url:\n",
354
  " model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
355
  " model_name = data['files'][1]['name']\n",
@@ -401,9 +401,9 @@
401
  " model_id = url.split('/')[-1]\n",
402
  " clean_url = url.split('?')[0]\n",
403
  "\n",
404
- " data = get_data_from_api(model_id, civitai_token)\n",
405
  " if data:\n",
406
- " model_type, model_name, image_url = extract_model_info(data, url, support_types)\n",
407
  " if model_name and image_url:\n",
408
  " image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)\n",
409
  " if any(types in model_type for types in support_types):\n",
@@ -415,9 +415,9 @@
415
  " \"\"\" information output \"\"\"\n",
416
  " # -- wrold's best print info --\n",
417
  " print(f\"\\n\\033[32m{'---'*45}\\n\\033[33mURL: \\033[34m{clean_url if 'civitai' in url else url}\\n\\033[33mSAVE DIR: \\033[34m{dst_dir}\\n\\033[33mFILE NAME: \\033[34m{file_name if not 'huggingface' in url else basename}\\033[0m\")\n",
418
- " print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\") if 'civitai' in url and not data else None\n",
419
  " if 'civitai' in url and data and any(types in model_type for types in support_types) and (locals().get('image_file_name') or ''):\n",
420
- " print(f\"\\033[32m[Preview DL]:\\033[0m {image_file_name} - {image_url}\")\n",
421
  " # ===================\n",
422
  "\n",
423
  " # -- GDrive --\n",
@@ -505,7 +505,7 @@
505
  "\n",
506
  "submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
507
  "submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
508
- "submodels += add_submodels(controlnet, \"\" if controlnet == \"ALL\" else controlnet_Num, controlnet_list, control_dir) # controlnet\n",
509
  "\n",
510
  "for submodel in submodels:\n",
511
  " if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
 
27
  "\n",
28
  "# ================= DETECT ENV =================\n",
29
  "def detect_environment():\n",
30
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
31
  " environments = {\n",
32
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
33
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
 
338
  "\n",
339
  "''' Get Image Preview | CivitAi '''\n",
340
  "\n",
341
+ "def get_data_from_api(model_id): # get model data\n",
342
+ " endpoint_url = f\"https://civitai.com/api/v1/model-versions/{model_id}\"\n",
343
  " headers = {\"Content-Type\": \"application/json\"}\n",
344
  " try:\n",
345
+ " response = requests.get(endpoint_url, headers=headers)\n",
346
  " if response.status_code == 200:\n",
347
  " return response.json()\n",
348
  " except requests.exceptions.RequestException as e:\n",
349
  " print(f\"An error occurred: {e}\")\n",
350
  " return None\n",
351
  "\n",
352
+ "def extract_model_info(data, url):\n",
353
  " if 'type=' in url:\n",
354
  " model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
355
  " model_name = data['files'][1]['name']\n",
 
401
  " model_id = url.split('/')[-1]\n",
402
  " clean_url = url.split('?')[0]\n",
403
  "\n",
404
+ " data = get_data_from_api(model_id)\n",
405
  " if data:\n",
406
+ " model_type, model_name, image_url = extract_model_info(data, url)\n",
407
  " if model_name and image_url:\n",
408
  " image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)\n",
409
  " if any(types in model_type for types in support_types):\n",
 
415
  " \"\"\" information output \"\"\"\n",
416
  " # -- wrold's best print info --\n",
417
  " print(f\"\\n\\033[32m{'---'*45}\\n\\033[33mURL: \\033[34m{clean_url if 'civitai' in url else url}\\n\\033[33mSAVE DIR: \\033[34m{dst_dir}\\n\\033[33mFILE NAME: \\033[34m{file_name if not 'huggingface' in url else basename}\\033[0m\")\n",
418
+ " print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\") if 'civitai' in url and not data else None\n",
419
  " if 'civitai' in url and data and any(types in model_type for types in support_types) and (locals().get('image_file_name') or ''):\n",
420
+ " print(f\"\\033[32m[Preview DL]:\\033[0m {image_file_name} - {image_url}\\n\")\n",
421
  " # ===================\n",
422
  "\n",
423
  " # -- GDrive --\n",
 
505
  "\n",
506
  "submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
507
  "submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
508
+ "submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet\n",
509
  "\n",
510
  "for submodel in submodels:\n",
511
  " if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
files_cells/notebooks/en/launch_en.ipynb CHANGED
@@ -36,7 +36,7 @@
36
  "\n",
37
  "# ================= DETECT ENV =================\n",
38
  "def detect_environment():\n",
39
- " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
40
  " environments = {\n",
41
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
42
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
 
36
  "\n",
37
  "# ================= DETECT ENV =================\n",
38
  "def detect_environment():\n",
39
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
40
  " environments = {\n",
41
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
42
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
files_cells/notebooks/en/widgets_en.ipynb CHANGED
@@ -29,7 +29,7 @@
29
  "\n",
30
  "# ================= DETECT ENV =================\n",
31
  "def detect_environment():\n",
32
- " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
33
  " environments = {\n",
34
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
35
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
 
29
  "\n",
30
  "# ================= DETECT ENV =================\n",
31
  "def detect_environment():\n",
32
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
33
  " environments = {\n",
34
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
35
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
files_cells/notebooks/ru/auto-cleaner_ru.ipynb CHANGED
@@ -28,7 +28,7 @@
28
  "\n",
29
  "# ================= DETECT ENV =================\n",
30
  "def detect_environment():\n",
31
- " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
32
  " environments = {\n",
33
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
34
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
 
28
  "\n",
29
  "# ================= DETECT ENV =================\n",
30
  "def detect_environment():\n",
31
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
32
  " environments = {\n",
33
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
34
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
files_cells/notebooks/ru/downloading_ru.ipynb CHANGED
@@ -27,7 +27,7 @@
27
  "\n",
28
  "# ================= DETECT ENV =================\n",
29
  "def detect_environment():\n",
30
- " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
31
  " environments = {\n",
32
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
33
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
@@ -338,18 +338,18 @@
338
  "\n",
339
  "''' Get Image Preview | CivitAi '''\n",
340
  "\n",
341
- "def get_data_from_api(model_id, api_key): # get model data\n",
342
- " base_url = f\"https://civitai.com/api/v1/model-versions/{model_id}\"\n",
343
  " headers = {\"Content-Type\": \"application/json\"}\n",
344
  " try:\n",
345
- " response = requests.get(base_url, headers=headers)\n",
346
  " if response.status_code == 200:\n",
347
  " return response.json()\n",
348
  " except requests.exceptions.RequestException as e:\n",
349
  " print(f\"An error occurred: {e}\")\n",
350
  " return None\n",
351
  "\n",
352
- "def extract_model_info(data, url, supported_types):\n",
353
  " if 'type=' in url:\n",
354
  " model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
355
  " model_name = data['files'][1]['name']\n",
@@ -401,9 +401,9 @@
401
  " model_id = url.split('/')[-1]\n",
402
  " clean_url = url.split('?')[0]\n",
403
  "\n",
404
- " data = get_data_from_api(model_id, civitai_token)\n",
405
  " if data:\n",
406
- " model_type, model_name, image_url = extract_model_info(data, url, support_types)\n",
407
  " if model_name and image_url:\n",
408
  " image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)\n",
409
  " if any(types in model_type for types in support_types):\n",
@@ -415,9 +415,9 @@
415
  " \"\"\" information output \"\"\"\n",
416
  " # -- wrold's best print info --\n",
417
  " print(f\"\\n\\033[32m{'---'*45}\\n\\033[33mURL: \\033[34m{clean_url if 'civitai' in url else url}\\n\\033[33mSAVE DIR: \\033[34m{dst_dir}\\n\\033[33mFILE NAME: \\033[34m{file_name if not 'huggingface' in url else basename}\\033[0m\")\n",
418
- " print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\") if 'civitai' in url and not data else None\n",
419
  " if 'civitai' in url and data and any(types in model_type for types in support_types) and (locals().get('image_file_name') or ''):\n",
420
- " print(f\"\\033[32m[Preview DL]:\\033[0m {image_file_name} - {image_url}\")\n",
421
  " # ===================\n",
422
  "\n",
423
  " # -- GDrive --\n",
@@ -505,7 +505,7 @@
505
  "\n",
506
  "submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
507
  "submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
508
- "submodels += add_submodels(controlnet, \"\" if controlnet == \"ALL\" else controlnet_Num, controlnet_list, control_dir) # controlnet\n",
509
  "\n",
510
  "for submodel in submodels:\n",
511
  " if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
 
27
  "\n",
28
  "# ================= DETECT ENV =================\n",
29
  "def detect_environment():\n",
30
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
31
  " environments = {\n",
32
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
33
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
 
338
  "\n",
339
  "''' Get Image Preview | CivitAi '''\n",
340
  "\n",
341
+ "def get_data_from_api(model_id): # get model data\n",
342
+ " endpoint_url = f\"https://civitai.com/api/v1/model-versions/{model_id}\"\n",
343
  " headers = {\"Content-Type\": \"application/json\"}\n",
344
  " try:\n",
345
+ " response = requests.get(endpoint_url, headers=headers)\n",
346
  " if response.status_code == 200:\n",
347
  " return response.json()\n",
348
  " except requests.exceptions.RequestException as e:\n",
349
  " print(f\"An error occurred: {e}\")\n",
350
  " return None\n",
351
  "\n",
352
+ "def extract_model_info(data, url):\n",
353
  " if 'type=' in url:\n",
354
  " model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
355
  " model_name = data['files'][1]['name']\n",
 
401
  " model_id = url.split('/')[-1]\n",
402
  " clean_url = url.split('?')[0]\n",
403
  "\n",
404
+ " data = get_data_from_api(model_id)\n",
405
  " if data:\n",
406
+ " model_type, model_name, image_url = extract_model_info(data, url)\n",
407
  " if model_name and image_url:\n",
408
  " image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)\n",
409
  " if any(types in model_type for types in support_types):\n",
 
415
  " \"\"\" information output \"\"\"\n",
416
  " # -- wrold's best print info --\n",
417
  " print(f\"\\n\\033[32m{'---'*45}\\n\\033[33mURL: \\033[34m{clean_url if 'civitai' in url else url}\\n\\033[33mSAVE DIR: \\033[34m{dst_dir}\\n\\033[33mFILE NAME: \\033[34m{file_name if not 'huggingface' in url else basename}\\033[0m\")\n",
418
+ " print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\") if 'civitai' in url and not data else None\n",
419
  " if 'civitai' in url and data and any(types in model_type for types in support_types) and (locals().get('image_file_name') or ''):\n",
420
+ " print(f\"\\033[32m[Preview DL]:\\033[0m {image_file_name} - {image_url}\\n\")\n",
421
  " # ===================\n",
422
  "\n",
423
  " # -- GDrive --\n",
 
505
  "\n",
506
  "submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
507
  "submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
508
+ "submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet\n",
509
  "\n",
510
  "for submodel in submodels:\n",
511
  " if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
files_cells/notebooks/ru/launch_ru.ipynb CHANGED
@@ -36,7 +36,7 @@
36
  "\n",
37
  "# ================= DETECT ENV =================\n",
38
  "def detect_environment():\n",
39
- " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
40
  " environments = {\n",
41
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
42
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
 
36
  "\n",
37
  "# ================= DETECT ENV =================\n",
38
  "def detect_environment():\n",
39
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
40
  " environments = {\n",
41
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
42
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
files_cells/notebooks/ru/widgets_ru.ipynb CHANGED
@@ -29,7 +29,7 @@
29
  "\n",
30
  "# ================= DETECT ENV =================\n",
31
  "def detect_environment():\n",
32
- " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
33
  " environments = {\n",
34
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
35
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
 
29
  "\n",
30
  "# ================= DETECT ENV =================\n",
31
  "def detect_environment():\n",
32
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
33
  " environments = {\n",
34
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
35
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
files_cells/python/en/downloading_en.py CHANGED
@@ -17,7 +17,7 @@ from urllib.parse import urlparse, parse_qs
17
 
18
  # ================= DETECT ENV =================
19
  def detect_environment():
20
- free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
21
  environments = {
22
  'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
23
  'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content")
@@ -328,18 +328,18 @@ user_header = f"\"Authorization: Bearer {hf_token}\""
328
 
329
  ''' Get Image Preview | CivitAi '''
330
 
331
- def get_data_from_api(model_id, api_key): # get model data
332
- base_url = f"https://civitai.com/api/v1/model-versions/{model_id}"
333
  headers = {"Content-Type": "application/json"}
334
  try:
335
- response = requests.get(base_url, headers=headers)
336
  if response.status_code == 200:
337
  return response.json()
338
  except requests.exceptions.RequestException as e:
339
  print(f"An error occurred: {e}")
340
  return None
341
 
342
- def extract_model_info(data, url, supported_types):
343
  if 'type=' in url:
344
  model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
345
  model_name = data['files'][1]['name']
@@ -391,9 +391,9 @@ def manual_download(url, dst_dir, file_name):
391
  model_id = url.split('/')[-1]
392
  clean_url = url.split('?')[0]
393
 
394
- data = get_data_from_api(model_id, civitai_token)
395
  if data:
396
- model_type, model_name, image_url = extract_model_info(data, url, support_types)
397
  if model_name and image_url:
398
  image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)
399
  if any(types in model_type for types in support_types):
@@ -405,9 +405,9 @@ def manual_download(url, dst_dir, file_name):
405
  """ information output """
406
  # -- wrold's best print info --
407
  print(f"\n\033[32m{'---'*45}\n\033[33mURL: \033[34m{clean_url if 'civitai' in url else url}\n\033[33mSAVE DIR: \033[34m{dst_dir}\n\033[33mFILE NAME: \033[34m{file_name if not 'huggingface' in url else basename}\033[0m")
408
- print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.") if 'civitai' in url and not data else None
409
  if 'civitai' in url and data and any(types in model_type for types in support_types) and (locals().get('image_file_name') or ''):
410
- print(f"\033[32m[Preview DL]:\033[0m {image_file_name} - {image_url}")
411
  # ===================
412
 
413
  # -- GDrive --
@@ -495,7 +495,7 @@ def add_submodels(selection, num_selection, model_dict, dst_dir):
495
 
496
  submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
497
  submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
498
- submodels += add_submodels(controlnet, "" if controlnet == "ALL" else controlnet_Num, controlnet_list, control_dir) # controlnet
499
 
500
  for submodel in submodels:
501
  if not Inpainting_Model and "inpainting" in submodel['name']:
 
17
 
18
  # ================= DETECT ENV =================
19
  def detect_environment():
20
+ free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
21
  environments = {
22
  'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
23
  'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content")
 
328
 
329
  ''' Get Image Preview | CivitAi '''
330
 
331
+ def get_data_from_api(model_id): # get model data
332
+ endpoint_url = f"https://civitai.com/api/v1/model-versions/{model_id}"
333
  headers = {"Content-Type": "application/json"}
334
  try:
335
+ response = requests.get(endpoint_url, headers=headers)
336
  if response.status_code == 200:
337
  return response.json()
338
  except requests.exceptions.RequestException as e:
339
  print(f"An error occurred: {e}")
340
  return None
341
 
342
+ def extract_model_info(data, url):
343
  if 'type=' in url:
344
  model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
345
  model_name = data['files'][1]['name']
 
391
  model_id = url.split('/')[-1]
392
  clean_url = url.split('?')[0]
393
 
394
+ data = get_data_from_api(model_id)
395
  if data:
396
+ model_type, model_name, image_url = extract_model_info(data, url)
397
  if model_name and image_url:
398
  image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)
399
  if any(types in model_type for types in support_types):
 
405
  """ information output """
406
  # -- wrold's best print info --
407
  print(f"\n\033[32m{'---'*45}\n\033[33mURL: \033[34m{clean_url if 'civitai' in url else url}\n\033[33mSAVE DIR: \033[34m{dst_dir}\n\033[33mFILE NAME: \033[34m{file_name if not 'huggingface' in url else basename}\033[0m")
408
+ print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n") if 'civitai' in url and not data else None
409
  if 'civitai' in url and data and any(types in model_type for types in support_types) and (locals().get('image_file_name') or ''):
410
+ print(f"\033[32m[Preview DL]:\033[0m {image_file_name} - {image_url}\n")
411
  # ===================
412
 
413
  # -- GDrive --
 
495
 
496
  submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
497
  submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
498
+ submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet
499
 
500
  for submodel in submodels:
501
  if not Inpainting_Model and "inpainting" in submodel['name']:
files_cells/python/ru/downloading_ru.py CHANGED
@@ -17,7 +17,7 @@ from urllib.parse import urlparse, parse_qs
17
 
18
  # ================= DETECT ENV =================
19
  def detect_environment():
20
- free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
21
  environments = {
22
  'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
23
  'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content")
@@ -328,18 +328,18 @@ user_header = f"\"Authorization: Bearer {hf_token}\""
328
 
329
  ''' Get Image Preview | CivitAi '''
330
 
331
- def get_data_from_api(model_id, api_key): # get model data
332
- base_url = f"https://civitai.com/api/v1/model-versions/{model_id}"
333
  headers = {"Content-Type": "application/json"}
334
  try:
335
- response = requests.get(base_url, headers=headers)
336
  if response.status_code == 200:
337
  return response.json()
338
  except requests.exceptions.RequestException as e:
339
  print(f"An error occurred: {e}")
340
  return None
341
 
342
- def extract_model_info(data, url, supported_types):
343
  if 'type=' in url:
344
  model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
345
  model_name = data['files'][1]['name']
@@ -391,9 +391,9 @@ def manual_download(url, dst_dir, file_name):
391
  model_id = url.split('/')[-1]
392
  clean_url = url.split('?')[0]
393
 
394
- data = get_data_from_api(model_id, civitai_token)
395
  if data:
396
- model_type, model_name, image_url = extract_model_info(data, url, support_types)
397
  if model_name and image_url:
398
  image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)
399
  if any(types in model_type for types in support_types):
@@ -405,9 +405,9 @@ def manual_download(url, dst_dir, file_name):
405
  """ information output """
406
  # -- wrold's best print info --
407
  print(f"\n\033[32m{'---'*45}\n\033[33mURL: \033[34m{clean_url if 'civitai' in url else url}\n\033[33mSAVE DIR: \033[34m{dst_dir}\n\033[33mFILE NAME: \033[34m{file_name if not 'huggingface' in url else basename}\033[0m")
408
- print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.") if 'civitai' in url and not data else None
409
  if 'civitai' in url and data and any(types in model_type for types in support_types) and (locals().get('image_file_name') or ''):
410
- print(f"\033[32m[Preview DL]:\033[0m {image_file_name} - {image_url}")
411
  # ===================
412
 
413
  # -- GDrive --
@@ -495,7 +495,7 @@ def add_submodels(selection, num_selection, model_dict, dst_dir):
495
 
496
  submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
497
  submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
498
- submodels += add_submodels(controlnet, "" if controlnet == "ALL" else controlnet_Num, controlnet_list, control_dir) # controlnet
499
 
500
  for submodel in submodels:
501
  if not Inpainting_Model and "inpainting" in submodel['name']:
 
17
 
18
  # ================= DETECT ENV =================
19
  def detect_environment():
20
+ free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
21
  environments = {
22
  'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
23
  'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content")
 
328
 
329
  ''' Get Image Preview | CivitAi '''
330
 
331
+ def get_data_from_api(model_id): # get model data
332
+ endpoint_url = f"https://civitai.com/api/v1/model-versions/{model_id}"
333
  headers = {"Content-Type": "application/json"}
334
  try:
335
+ response = requests.get(endpoint_url, headers=headers)
336
  if response.status_code == 200:
337
  return response.json()
338
  except requests.exceptions.RequestException as e:
339
  print(f"An error occurred: {e}")
340
  return None
341
 
342
+ def extract_model_info(data, url):
343
  if 'type=' in url:
344
  model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
345
  model_name = data['files'][1]['name']
 
391
  model_id = url.split('/')[-1]
392
  clean_url = url.split('?')[0]
393
 
394
+ data = get_data_from_api(model_id)
395
  if data:
396
+ model_type, model_name, image_url = extract_model_info(data, url)
397
  if model_name and image_url:
398
  image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)
399
  if any(types in model_type for types in support_types):
 
405
  """ information output """
406
  # -- wrold's best print info --
407
  print(f"\n\033[32m{'---'*45}\n\033[33mURL: \033[34m{clean_url if 'civitai' in url else url}\n\033[33mSAVE DIR: \033[34m{dst_dir}\n\033[33mFILE NAME: \033[34m{file_name if not 'huggingface' in url else basename}\033[0m")
408
+ print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n") if 'civitai' in url and not data else None
409
  if 'civitai' in url and data and any(types in model_type for types in support_types) and (locals().get('image_file_name') or ''):
410
+ print(f"\033[32m[Preview DL]:\033[0m {image_file_name} - {image_url}\n")
411
  # ===================
412
 
413
  # -- GDrive --
 
495
 
496
  submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
497
  submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
498
+ submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet
499
 
500
  for submodel in submodels:
501
  if not Inpainting_Model and "inpainting" in submodel['name']: