nonzeroexit commited on
Commit
357b75d
·
verified ·
1 Parent(s): 0c1f1e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -6
app.py CHANGED
@@ -176,13 +176,38 @@ def predictmic(sequence):
176
 
177
  return mic_results
178
 
179
- # Gradio interface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  iface = gr.Interface(
181
- fn=predict,
182
  inputs=gr.Textbox(label="Enter Protein Sequence"),
183
- outputs=gr.Label(label="Prediction"),
184
- title="AMP Classifier",
185
- description="Enter an amino acid sequence (e.g., FLPVLAGGL) to predict AMP."
 
 
 
 
186
  )
187
 
188
- iface.launch(share=True)
 
176
 
177
  return mic_results
178
 
179
+
180
+
181
+
182
+
183
+ def full_prediction(sequence):
184
+ # AMP prediction
185
+ features = extract_features(sequence)
186
+ if isinstance(features, str) and features.startswith("Error:"):
187
+ return "Error", 0.0, {}
188
+
189
+ prediction = model.predict(features)[0]
190
+ probabilities = model.predict_proba(features)[0]
191
+
192
+ amp_result = "Antimicrobial Peptide (AMP)" if prediction == 0 else "Non-AMP"
193
+ confidence = round(probabilities[0 if prediction == 0 else 1] * 100, 2)
194
+
195
+ # MIC prediction
196
+ mic_values = predictmic(sequence)
197
+
198
+ return amp_result, f"{confidence}%", mic_values
199
+
200
+ import gradio as gr
201
  iface = gr.Interface(
202
+ fn=full_prediction,
203
  inputs=gr.Textbox(label="Enter Protein Sequence"),
204
+ outputs=[
205
+ gr.Label(label="AMP Classification"),
206
+ gr.Label(label="Confidence"),
207
+ gr.JSON(label="Predicted MIC (µg/mL) for Each Bacterium")
208
+ ],
209
+ title="AMP & MIC Predictor",
210
+ description="Enter an amino acid sequence (e.g., FLPVLAGGL) to predict AMP class and MIC values across bacteria."
211
  )
212
 
213
+ iface.launch(share=True)