Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,7 @@ import io
|
|
9 |
import base64
|
10 |
import os
|
11 |
import huggingface_hub
|
12 |
-
from huggingface_hub import hf_hub_download
|
13 |
-
from huggingface_hub import login
|
14 |
-
|
15 |
-
|
16 |
|
17 |
# Load label mapping
|
18 |
label_to_int = pd.read_pickle('label_to_int.pkl')
|
@@ -52,11 +49,6 @@ def load_model():
|
|
52 |
input_size = 768 + metadata_features
|
53 |
log_reg = LogisticRegressionTorch(input_dim=input_size, output_dim=N_UNIQUE_CLASSES)
|
54 |
|
55 |
-
#model_weights_path = os.getenv('MODEL_PATH')
|
56 |
-
#weights = torch.load(model_weights_path, map_location=torch.device('cpu'))
|
57 |
-
|
58 |
-
|
59 |
-
# Ensure you are authenticated if the repository is private
|
60 |
token = os.getenv('HUGGINGFACE_TOKEN')
|
61 |
if token is None:
|
62 |
raise ValueError("HUGGINGFACE_TOKEN environment variable is not set")
|
@@ -79,7 +71,12 @@ def load_model():
|
|
79 |
|
80 |
model, tokenizer = load_model()
|
81 |
|
82 |
-
def analyze_dna(sequence):
|
|
|
|
|
|
|
|
|
|
|
83 |
try:
|
84 |
if not all(nucleotide in 'ACTGN' for nucleotide in sequence):
|
85 |
return {"error": "Sequence contains invalid characters"}, ""
|
@@ -114,7 +111,11 @@ def analyze_dna(sequence):
|
|
114 |
return {"error": str(e)}, ""
|
115 |
|
116 |
# Create a Gradio interface
|
117 |
-
demo = gr.Interface(
|
|
|
|
|
|
|
|
|
118 |
|
119 |
# Launch the interface
|
120 |
demo.launch()
|
|
|
9 |
import base64
|
10 |
import os
|
11 |
import huggingface_hub
|
12 |
+
from huggingface_hub import hf_hub_download, login
|
|
|
|
|
|
|
13 |
|
14 |
# Load label mapping
|
15 |
label_to_int = pd.read_pickle('label_to_int.pkl')
|
|
|
49 |
input_size = 768 + metadata_features
|
50 |
log_reg = LogisticRegressionTorch(input_dim=input_size, output_dim=N_UNIQUE_CLASSES)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
52 |
token = os.getenv('HUGGINGFACE_TOKEN')
|
53 |
if token is None:
|
54 |
raise ValueError("HUGGINGFACE_TOKEN environment variable is not set")
|
|
|
71 |
|
72 |
model, tokenizer = load_model()
|
73 |
|
74 |
+
def analyze_dna(sequence, password):
|
75 |
+
|
76 |
+
# put password into hidden HF variable later
|
77 |
+
if password != "test_pw":
|
78 |
+
return {"error": "Invalid password"}, ""
|
79 |
+
|
80 |
try:
|
81 |
if not all(nucleotide in 'ACTGN' for nucleotide in sequence):
|
82 |
return {"error": "Sequence contains invalid characters"}, ""
|
|
|
111 |
return {"error": str(e)}, ""
|
112 |
|
113 |
# Create a Gradio interface
|
114 |
+
demo = gr.Interface(
|
115 |
+
fn=analyze_dna,
|
116 |
+
inputs=[gr.inputs.Textbox(label="DNA Sequence"), gr.inputs.Textbox(label="Password", type="password")],
|
117 |
+
outputs=["json", "html"]
|
118 |
+
)
|
119 |
|
120 |
# Launch the interface
|
121 |
demo.launch()
|