xJuuzouYTx commited on
Commit
42cf67e
1 Parent(s): 66d588d

[ADD] error messages

Browse files
Files changed (4) hide show
  1. RVC_BOOK.ipynb +36 -0
  2. app.py +7 -0
  3. inference.py +6 -0
  4. utils/model.py +2 -17
RVC_BOOK.ipynb ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# <font color='#018ada'>ULTIVC Juuxn Version</font>\n",
8
+ "---\n",
9
+ "![youtube.png](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAJ1BMVEVHcEz/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/////mJj/wcH/jY3aUCqcAAAACHRSTlMA8czbELSvDrGIfzkAAABCSURBVBiVY2AgA7CwMTMycgABIyMzGztQgIkDCTABBThQAEyAixtNgIeTkwu/AIYWZEMxrGVhZWaE8BiZWVnI8RoAJWEEDt2WmW4AAAAASUVORK5CYII=) **[YouTube](https://www.youtube.com/@Juuxn)**\n",
10
+ "\n",
11
+ "**Enlaces que podrían interesarte:**\n",
12
+ "\n",
13
+ "- [Tutorial para este cuaderno](https://www.youtube.com/watch?v=gTWA2qyzX7k) - [Tutorial para cuaderno tradicional](https://www.youtube.com/embed/R8-PivPpv8o) - [Transferir archivo de mega a Drive](https://colab.research.google.com/drive/1utTesfmBv-uQ8Upa7TEVpM57kmcq9YN6?usp=sharing)\n",
14
+ "---"
15
+ ]
16
+ },
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": null,
20
+ "metadata": {
21
+ "vscode": {
22
+ "languageId": "plaintext"
23
+ }
24
+ },
25
+ "outputs": [],
26
+ "source": []
27
+ }
28
+ ],
29
+ "metadata": {
30
+ "language_info": {
31
+ "name": "python"
32
+ }
33
+ },
34
+ "nbformat": 4,
35
+ "nbformat_minor": 2
36
+ }
app.py CHANGED
@@ -70,6 +70,13 @@ def infer(model, f0_method, audio_file):
70
  def post_model(name, model_url, version, creator):
71
  modelname = model_downloader(model_url, zips_folder, unzips_folder)
72
  model_files = get_model(unzips_folder, modelname)
 
 
 
 
 
 
 
73
  md5_hash = calculate_md5(os.path.join(unzips_folder,model_files['pth']))
74
  zipfile = compress(modelname, list(model_files.values()))
75
  file_to_upload = open(zipfile, "rb")
 
70
  def post_model(name, model_url, version, creator):
71
  modelname = model_downloader(model_url, zips_folder, unzips_folder)
72
  model_files = get_model(unzips_folder, modelname)
73
+
74
+ if not model_files:
75
+ return "No se encontrado un modelo valido, verifica el contenido del enlace e intentalo más tarde."
76
+
77
+ if not model_files.get('pth'):
78
+ return "No se encontrado un modelo valido, verifica el contenido del enlace e intentalo más tarde."
79
+
80
  md5_hash = calculate_md5(os.path.join(unzips_folder,model_files['pth']))
81
  zipfile = compress(modelname, list(model_files.values()))
82
  file_to_upload = open(zipfile, "rb")
inference.py CHANGED
@@ -198,6 +198,12 @@ class Inference:
198
  modelname = model.model_downloader(self._model_name, "./zips/", "./weights/")
199
 
200
  model_info = model.get_model(os.path.join(current_dir, 'weights') , modelname)
 
 
 
 
 
 
201
  index = model_info.get('index', '')
202
  pth = model_info.get('pth', None)
203
 
 
198
  modelname = model.model_downloader(self._model_name, "./zips/", "./weights/")
199
 
200
  model_info = model.get_model(os.path.join(current_dir, 'weights') , modelname)
201
+ if not model_info:
202
+ return "No se encontrado un modelo valido, verifica el contenido del enlace e intentalo más tarde."
203
+
204
+ if not model_info.get('pth'):
205
+ return "No se encontrado un modelo valido, verifica el contenido del enlace e intentalo más tarde."
206
+
207
  index = model_info.get('index', '')
208
  pth = model_info.get('pth', None)
209
 
utils/model.py CHANGED
@@ -100,27 +100,12 @@ def model_downloader(url, zip_path, dest_path):
100
  else:
101
  return None
102
 
103
-
104
- def get_models(weight_path):
105
- # Obtener todos los elementos en la ruta
106
- files = os.listdir(weight_path)
107
- # Filtrar solo los directorios
108
- return [file for file in files if os.path.isdir(os.path.join(weight_path, file))]
109
-
110
-
111
  def get_model(weight_path, modelname):
112
  resources = {}
113
  for root, dirs, files in os.walk(os.path.join(weight_path, modelname)):
114
  for file in files:
115
  if file.endswith('.index'):
116
  resources['index'] = os.path.relpath(os.path.join(root, file))
117
- if file.endswith('.pth'):
118
  resources['pth'] = os.path.relpath(os.path.join(root, file), start=weight_path)
119
- return resources
120
-
121
-
122
- def get_audios(audios_path):
123
- # Obtener todos los elementos en la ruta
124
- files = os.listdir(audios_path)
125
- # Filtrar solo los directorios
126
- return [file for file in files if not os.path.isdir(os.path.join(audios_path, file)) and os.path.join(audios_path, file).endswith(('.mp3', '.wav'))]
 
100
  else:
101
  return None
102
 
 
 
 
 
 
 
 
 
103
  def get_model(weight_path, modelname):
104
  resources = {}
105
  for root, dirs, files in os.walk(os.path.join(weight_path, modelname)):
106
  for file in files:
107
  if file.endswith('.index'):
108
  resources['index'] = os.path.relpath(os.path.join(root, file))
109
+ if file.endswith('.pth') and not 'G_' in file and not 'D_' in file:
110
  resources['pth'] = os.path.relpath(os.path.join(root, file), start=weight_path)
111
+ return resources