seawolf2357 commited on
Commit
de0bdde
ยท
verified ยท
1 Parent(s): 4208724

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +102 -11
app.py CHANGED
@@ -822,7 +822,7 @@ def deploy_to_huggingface(code: str):
822
 
823
  # Import ๋ฌธ ์ถ”์ถœ ๋ฐ requirements.txt ์ƒ์„ฑ์„ ์œ„ํ•œ ๋งคํ•‘
824
  import_mapping = {
825
- 'gradio': 'gradio>=4.0.0',
826
  'numpy': 'numpy',
827
  'pandas': 'pandas',
828
  'torch': 'torch',
@@ -833,23 +833,114 @@ def deploy_to_huggingface(code: str):
833
  'cv2': 'opencv-python',
834
  'sklearn': 'scikit-learn',
835
  'tensorflow': 'tensorflow',
836
- 'scipy': 'scipy'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
837
  }
838
 
839
  required_packages = set(['gradio>=4.0.0']) # gradio๋Š” ๊ธฐ๋ณธ์œผ๋กœ ํฌํ•จ
840
 
841
  # ์ฝ”๋“œ์—์„œ import ๋ฌธ ๋ถ„์„
 
 
842
  for line in code.split('\n'):
 
843
  if line.startswith('import ') or line.startswith('from '):
844
- # 'import' ๋˜๋Š” 'from' ๋ฌธ์—์„œ ํŒจํ‚ค์ง€ ์ด๋ฆ„ ์ถ”์ถœ
845
- if line.startswith('import '):
846
- package = line.split('import ')[1].split()[0].split('.')[0]
847
- else:
848
- package = line.split('from ')[1].split()[0].split('.')[0]
849
-
850
- if package in import_mapping:
851
- required_packages.add(import_mapping[package])
852
-
 
 
853
  # 7) ์ „์ฒด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ฝ”๋“œ ์ƒ์„ฑ
854
  full_app_code = code
855
 
 
822
 
823
  # Import ๋ฌธ ์ถ”์ถœ ๋ฐ requirements.txt ์ƒ์„ฑ์„ ์œ„ํ•œ ๋งคํ•‘
824
  import_mapping = {
825
+ 'gradio': 'gradio==5.6.0',
826
  'numpy': 'numpy',
827
  'pandas': 'pandas',
828
  'torch': 'torch',
 
833
  'cv2': 'opencv-python',
834
  'sklearn': 'scikit-learn',
835
  'tensorflow': 'tensorflow',
836
+ 'scipy': 'scipy',
837
+ 'librosa': 'librosa',
838
+ 'soundfile': 'soundfile',
839
+ 'nltk': 'nltk',
840
+ 'spacy': 'spacy',
841
+ 'gensim': 'gensim',
842
+ 'keras': 'keras',
843
+ 'seaborn': 'seaborn',
844
+ 'bokeh': 'bokeh',
845
+ 'requests': 'requests',
846
+ 'beautifulsoup4': 'beautifulsoup4',
847
+ 'scikit-image': 'scikit-image',
848
+ 'opencv-python': 'opencv-python',
849
+ 'tqdm': 'tqdm',
850
+ 'streamlit': 'streamlit',
851
+ 'dash': 'dash',
852
+ 'flask': 'flask',
853
+ 'django': 'django',
854
+ 'sqlalchemy': 'sqlalchemy',
855
+ 'pymongo': 'pymongo',
856
+ 'redis': 'redis',
857
+ 'psycopg2': 'psycopg2-binary',
858
+ 'mysql-connector': 'mysql-connector-python',
859
+ 'pytest': 'pytest',
860
+ 'unittest': 'unittest2',
861
+ 'sphinx': 'sphinx',
862
+ 'jupyter': 'jupyter',
863
+ 'ipython': 'ipython',
864
+ 'fastapi': 'fastapi',
865
+ 'uvicorn': 'uvicorn',
866
+ 'aiohttp': 'aiohttp',
867
+ 'websockets': 'websockets',
868
+ 'pyyaml': 'pyyaml',
869
+ 'json': 'json5',
870
+ 'xml': 'lxml',
871
+ 'html': 'html5lib',
872
+ 'urllib3': 'urllib3',
873
+ 'cryptography': 'cryptography',
874
+ 'bcrypt': 'bcrypt',
875
+ 'jwt': 'pyjwt',
876
+ 'pillow': 'Pillow',
877
+ 'imageio': 'imageio',
878
+ 'moviepy': 'moviepy',
879
+ 'ffmpeg': 'ffmpeg-python',
880
+ 'pydub': 'pydub',
881
+ 'wave': 'wave',
882
+ 'pyaudio': 'pyaudio',
883
+ 'sounddevice': 'sounddevice',
884
+ 'pygame': 'pygame',
885
+ 'kivy': 'kivy',
886
+ 'pyqt5': 'PyQt5',
887
+ 'tkinter': 'tk',
888
+ 'wx': 'wxPython',
889
+ 'pyside2': 'PySide2',
890
+ 'deap': 'deap',
891
+ 'gym': 'gym',
892
+ 'stable-baselines3': 'stable-baselines3',
893
+ 'optuna': 'optuna',
894
+ 'hyperopt': 'hyperopt',
895
+ 'ray': 'ray',
896
+ 'dask': 'dask',
897
+ 'vaex': 'vaex',
898
+ 'modin': 'modin',
899
+ 'cupy': 'cupy',
900
+ 'jax': 'jax',
901
+ 'numba': 'numba',
902
+ 'cython': 'cython',
903
+ 'sympy': 'sympy',
904
+ 'statsmodels': 'statsmodels',
905
+ 'prophet': 'prophet',
906
+ 'lightgbm': 'lightgbm',
907
+ 'xgboost': 'xgboost',
908
+ 'catboost': 'catboost',
909
+ 'shap': 'shap',
910
+ 'lime': 'lime',
911
+ 'eli5': 'eli5',
912
+ 'yellowbrick': 'yellowbrick',
913
+ 'altair': 'altair',
914
+ 'plotnine': 'plotnine',
915
+ 'folium': 'folium',
916
+ 'geopandas': 'geopandas',
917
+ 'shapely': 'shapely',
918
+ 'rasterio': 'rasterio',
919
+ 'networkx': 'networkx',
920
+ 'graphviz': 'graphviz',
921
+ 'pydot': 'pydot',
922
+ 'pygraphviz': 'pygraphviz'
923
  }
924
 
925
  required_packages = set(['gradio>=4.0.0']) # gradio๋Š” ๊ธฐ๋ณธ์œผ๋กœ ํฌํ•จ
926
 
927
  # ์ฝ”๋“œ์—์„œ import ๋ฌธ ๋ถ„์„
928
+ import_pattern = r'^(?:from\s+(\S+)|import\s+([^,\s]+)(?:\s*,\s*([^,\s]+))*)'
929
+
930
  for line in code.split('\n'):
931
+ line = line.strip()
932
  if line.startswith('import ') or line.startswith('from '):
933
+ matches = re.match(import_pattern, line)
934
+ if matches:
935
+ if matches.group(1): # from ... import ...
936
+ package = matches.group(1).split('.')[0]
937
+ else: # import ...
938
+ packages = [p.strip() for p in re.findall(r'[\w.]+', line[7:])]
939
+ for package in packages:
940
+ package = package.split('.')[0]
941
+ if package in import_mapping:
942
+ required_packages.add(import_mapping[package])
943
+
944
  # 7) ์ „์ฒด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ฝ”๋“œ ์ƒ์„ฑ
945
  full_app_code = code
946