nonzeroexit commited on
Commit
14f4c95
·
verified ·
1 Parent(s): 942bf87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -1,20 +1,13 @@
1
- from fastapi import FastAPI
2
  import joblib
3
- import numpy as np
4
-
5
- app = FastAPI()
6
 
7
  # Load your trained model
8
  model = joblib.load("SVM.joblib") # Ensure this file is in the correct directory
9
 
10
- @app.get("/")
11
- def home():
12
- return {"message": "AMP Classifier API is running!"}
 
 
13
 
14
- @app.post("/predict")
15
- def predict(sequence: str):
16
- # Convert sequence to features (modify if needed)
17
- features = np.array([len(sequence)]) # Example: length of sequence
18
- prediction = model.predict([features])
19
-
20
- return {"sequence": sequence, "is_AMP": bool(prediction[0])}
 
1
+ import gradio as gr
2
  import joblib
 
 
 
3
 
4
  # Load your trained model
5
  model = joblib.load("SVM.joblib") # Ensure this file is in the correct directory
6
 
7
+ def predict(sequence):
8
+ prediction = model.predict([len(sequence)]) # Adjust based on your features
9
+ return "AMP" if prediction[0] else "Non-AMP"
10
+
11
+ iface = gr.Interface(fn=predict, inputs="text", outputs="text")
12
 
13
+ iface.launch()