Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ device = 'cuda:0'
|
|
| 12 |
model_v1, tokenizer_v1 = None, None
|
| 13 |
model_path_v1 = r'ssocean/NAIP'
|
| 14 |
|
|
|
|
| 15 |
def predict_v1(title, abstract):
|
| 16 |
global model_v1, tokenizer_v1
|
| 17 |
if model_v1 is None:
|
|
@@ -37,6 +38,7 @@ def predict_v1(title, abstract):
|
|
| 37 |
scorer_v2 = None
|
| 38 |
model_path_v2 = r'ssocean/NAIPv2'
|
| 39 |
|
|
|
|
| 40 |
class PaperScorer:
|
| 41 |
def __init__(self, model_path: str, device: str = 'cuda', max_length: int = 512):
|
| 42 |
self.device = torch.device(device if torch.cuda.is_available() else 'cpu')
|
|
@@ -75,8 +77,7 @@ def predict_v2(title, abstract):
|
|
| 75 |
return scorer_v2.score(title, abstract)
|
| 76 |
|
| 77 |
|
| 78 |
-
|
| 79 |
-
@spaces.GPU(duration=60, enable_queue=True)
|
| 80 |
def predict(title, abstract, model_version):
|
| 81 |
title = title.replace("\n", " ").strip().replace('’', "'")
|
| 82 |
abstract = abstract.replace("\n", " ").strip().replace('’', "'")
|
|
@@ -97,7 +98,7 @@ def predict(title, abstract, model_version):
|
|
| 97 |
return score
|
| 98 |
|
| 99 |
|
| 100 |
-
|
| 101 |
def validate_input(title, abstract):
|
| 102 |
title = title.replace("\n", " ").strip().replace('’', "'")
|
| 103 |
abstract = abstract.replace("\n", " ").strip().replace('’', "'")
|
|
@@ -127,7 +128,7 @@ def update_button_status(title, abstract):
|
|
| 127 |
return gr.update(value=message), gr.update(interactive=True)
|
| 128 |
|
| 129 |
|
| 130 |
-
|
| 131 |
examples = [
|
| 132 |
[
|
| 133 |
"SARDet-100K: Towards Open-Source Benchmark and ToolKit for Large-Scale SAR Object Detection",
|
|
|
|
| 12 |
model_v1, tokenizer_v1 = None, None
|
| 13 |
model_path_v1 = r'ssocean/NAIP'
|
| 14 |
|
| 15 |
+
@spaces.GPU(duration=60, enable_queue=True)
|
| 16 |
def predict_v1(title, abstract):
|
| 17 |
global model_v1, tokenizer_v1
|
| 18 |
if model_v1 is None:
|
|
|
|
| 38 |
scorer_v2 = None
|
| 39 |
model_path_v2 = r'ssocean/NAIPv2'
|
| 40 |
|
| 41 |
+
@spaces.GPU(duration=60, enable_queue=True)
|
| 42 |
class PaperScorer:
|
| 43 |
def __init__(self, model_path: str, device: str = 'cuda', max_length: int = 512):
|
| 44 |
self.device = torch.device(device if torch.cuda.is_available() else 'cpu')
|
|
|
|
| 77 |
return scorer_v2.score(title, abstract)
|
| 78 |
|
| 79 |
|
| 80 |
+
|
|
|
|
| 81 |
def predict(title, abstract, model_version):
|
| 82 |
title = title.replace("\n", " ").strip().replace('’', "'")
|
| 83 |
abstract = abstract.replace("\n", " ").strip().replace('’', "'")
|
|
|
|
| 98 |
return score
|
| 99 |
|
| 100 |
|
| 101 |
+
|
| 102 |
def validate_input(title, abstract):
|
| 103 |
title = title.replace("\n", " ").strip().replace('’', "'")
|
| 104 |
abstract = abstract.replace("\n", " ").strip().replace('’', "'")
|
|
|
|
| 128 |
return gr.update(value=message), gr.update(interactive=True)
|
| 129 |
|
| 130 |
|
| 131 |
+
|
| 132 |
examples = [
|
| 133 |
[
|
| 134 |
"SARDet-100K: Towards Open-Source Benchmark and ToolKit for Large-Scale SAR Object Detection",
|