Spaces:
Running
Running
antoinedelplace
commited on
Commit
·
6dadf7f
1
Parent(s):
6bb9743
Automatic weight download
Browse files- app.py +5 -0
- asp/util/io_utils.py +13 -0
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
|
@@ -11,6 +13,7 @@ from PIL import Image
|
|
11 |
from asp.models.cpt_model import CPTModel
|
12 |
from asp.data.base_dataset import get_transform
|
13 |
from asp.util.general_utils import parse_args
|
|
|
14 |
|
15 |
def transform_with_seed(input_img, transform, seed=123456):
|
16 |
random.seed(seed)
|
@@ -74,6 +77,8 @@ def convert_he2ihc(input_he_image_path):
|
|
74 |
return output_img
|
75 |
|
76 |
def main():
|
|
|
|
|
77 |
demo = gr.Interface(
|
78 |
fn=convert_he2ihc,
|
79 |
inputs=gr.Image(type="filepath"),
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import gradio as gr
|
4 |
import numpy as np
|
5 |
|
|
|
13 |
from asp.models.cpt_model import CPTModel
|
14 |
from asp.data.base_dataset import get_transform
|
15 |
from asp.util.general_utils import parse_args
|
16 |
+
from asp.util.io_utils import download_weights
|
17 |
|
18 |
def transform_with_seed(input_img, transform, seed=123456):
|
19 |
random.seed(seed)
|
|
|
77 |
return output_img
|
78 |
|
79 |
def main():
|
80 |
+
download_weights("1SMTeMprETgXAfJGXQz0LtgXXetfKXNaW", "../../checkpoints/ASP_pretrained/BCI_her2_zero_uniform/latest_net_G.pth")
|
81 |
+
|
82 |
demo = gr.Interface(
|
83 |
fn=convert_he2ihc,
|
84 |
inputs=gr.Image(type="filepath"),
|
asp/util/io_utils.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gdown
|
3 |
+
|
4 |
+
|
5 |
+
def download_weights(file_id, weights_path):
|
6 |
+
if os.path.exists(weights_path):
|
7 |
+
print(f"Weights already exist at {weights_path}.")
|
8 |
+
return
|
9 |
+
|
10 |
+
os.makedirs(os.path.dirname(weights_path), exist_ok=True)
|
11 |
+
|
12 |
+
url = f"https://drive.google.com/uc?id={file_id}"
|
13 |
+
gdown.download(url, weights_path, quiet=False)
|
requirements.txt
CHANGED
@@ -6,4 +6,5 @@ packaging
|
|
6 |
opencv-python
|
7 |
GPUtil
|
8 |
|
9 |
-
gradio
|
|
|
|
6 |
opencv-python
|
7 |
GPUtil
|
8 |
|
9 |
+
gradio
|
10 |
+
gdown
|