copilot-swe-agent[bot] raylim commited on
Commit
fe38b5b
·
1 Parent(s): 2a074d9

Add HF Spaces deployment documentation and clean up imports

Browse files

Co-authored-by: raylim <3074310+raylim@users.noreply.github.com>

Files changed (2) hide show
  1. README.md +26 -0
  2. app.py +1 -1
README.md CHANGED
@@ -19,6 +19,7 @@ Mosaic is a deep learning model designed for predicting cancer subtypes and biom
19
  - [System Requirements](#system-requirements)
20
  - [Pre-requisites](#pre-requisites)
21
  - [Installation](#installation)
 
22
  - [Usage](#usage)
23
  - [Initial Setup](#initial-setup)
24
  - [Web Application](#web-application)
@@ -63,6 +64,31 @@ Alternatively, install directly from the repository:
63
  uv pip install git+https://github.com/pathology-data-mining/mosaic.git
64
  ```
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  ## Usage
67
 
68
  ### Initial Setup
 
19
  - [System Requirements](#system-requirements)
20
  - [Pre-requisites](#pre-requisites)
21
  - [Installation](#installation)
22
+ - [Deploying to Hugging Face Spaces](#deploying-to-hugging-face-spaces)
23
  - [Usage](#usage)
24
  - [Initial Setup](#initial-setup)
25
  - [Web Application](#web-application)
 
64
  uv pip install git+https://github.com/pathology-data-mining/mosaic.git
65
  ```
66
 
67
+ ## Deploying to Hugging Face Spaces
68
+
69
+ This repository is configured for deployment on Hugging Face Spaces with Zero GPU support.
70
+
71
+ ### Prerequisites
72
+
73
+ 1. You need to be added to the [PDM Group](https://huggingface.co/PDM-Group) on Hugging Face to access the models
74
+ 2. Create a Hugging Face access token with read permissions for the PDM-Group space
75
+
76
+ ### Deployment Steps
77
+
78
+ 1. Create a new Space on Hugging Face
79
+ 2. Select "Gradio" as the SDK
80
+ 3. Choose "Zero GPU" as the hardware option (if available)
81
+ 4. Clone this repository to your Space or push the code
82
+ 5. In your Space settings, add a secret named `HF_TOKEN` with your Hugging Face access token
83
+ 6. The app will automatically start and download the necessary models on first run
84
+
85
+ ### Zero GPU Configuration
86
+
87
+ The app uses the `@spaces.GPU` decorator to allocate GPU resources only when needed for inference. This allows efficient use of Zero GPU resources on Hugging Face Spaces. The GPU is automatically allocated when:
88
+ - Processing tissue segmentation
89
+ - Extracting features with CTransPath and Optimus models
90
+ - Running Aeon and Paladin model inference
91
+
92
  ## Usage
93
 
94
  ### Initial Setup
app.py CHANGED
@@ -4,7 +4,7 @@ This module serves as the main entry point when deploying Mosaic to
4
  Hugging Face Spaces. It initializes the models and launches the Gradio interface.
5
  """
6
 
7
- from mosaic.gradio_app import download_and_process_models, main
8
  from mosaic.ui import launch_gradio
9
 
10
  if __name__ == "__main__":
 
4
  Hugging Face Spaces. It initializes the models and launches the Gradio interface.
5
  """
6
 
7
+ from mosaic.gradio_app import download_and_process_models
8
  from mosaic.ui import launch_gradio
9
 
10
  if __name__ == "__main__":