raylim commited on
Commit
598bc26
·
unverified ·
1 Parent(s): db7a6f0

Fix HF Spaces build: remove -e . from requirements, add setup.py, auto-install in app.py

Browse files
Files changed (3) hide show
  1. app.py +9 -0
  2. requirements.txt +0 -1
  3. setup.py +10 -0
app.py CHANGED
@@ -6,6 +6,15 @@ Hugging Face Spaces. It initializes the models and launches the Gradio interface
6
 
7
  import os
8
  import subprocess
 
 
 
 
 
 
 
 
 
9
 
10
  from mosaic.gradio_app import download_and_process_models
11
  from mosaic.ui import launch_gradio
 
6
 
7
  import os
8
  import subprocess
9
+ import sys
10
+
11
+ # Install the mosaic package if not already installed
12
+ try:
13
+ import mosaic
14
+ except ImportError:
15
+ print("Installing mosaic package...")
16
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", "."])
17
+ import mosaic
18
 
19
  from mosaic.gradio_app import download_and_process_models
20
  from mosaic.ui import launch_gradio
requirements.txt CHANGED
@@ -13,4 +13,3 @@ requests>=2.31.0
13
  huggingface-hub>=0.20.0
14
  openslide-python>=1.3.0
15
  git+https://github.com/pathology-data-mining/Mussel.git@ray-dev
16
- -e .
 
13
  huggingface-hub>=0.20.0
14
  openslide-python>=1.3.0
15
  git+https://github.com/pathology-data-mining/Mussel.git@ray-dev
 
setup.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ """Setup script for Mosaic package."""
2
+ from setuptools import setup, find_packages
3
+
4
+ setup(
5
+ name="mosaic",
6
+ version="0.1.0",
7
+ package_dir={"": "src"},
8
+ packages=find_packages(where="src"),
9
+ python_requires=">=3.10",
10
+ )