Update app.py
Browse files
app.py
CHANGED
|
@@ -26,23 +26,28 @@ pkgs = freeze.freeze()
|
|
| 26 |
for pkg in pkgs: print(pkg)
|
| 27 |
class Query(BaseModel):
|
| 28 |
smiles :List[str]
|
| 29 |
-
|
|
|
|
| 30 |
rob_chem_model = ClassificationModel('roberta', 'BasselAhmed/RobertaChemClinToxTuned',use_cuda=False ,args={'evaluate_each_epoch':True , 'evaluate_during_training_verbose':True, 'seed':4})
|
| 31 |
|
| 32 |
-
@app.post("/ToxicityPrediction")
|
| 33 |
-
def c(query:Query):
|
| 34 |
print(query)
|
| 35 |
print(type(query))
|
| 36 |
query_dict = query.dict()
|
| 37 |
try:
|
| 38 |
predictions, raw_outputs = rob_chem_model.predict([str(query.smiles)])
|
| 39 |
print(predictions)
|
|
|
|
| 40 |
#json_compatible_item_data = jsonable_encoder(predictions[0])
|
| 41 |
#return JSONResponse(content=json_compatible_item_data)
|
| 42 |
query_dict.update({"predictions":predictions})
|
|
|
|
|
|
|
| 43 |
#answer = {"prediction":predictions[0]}
|
| 44 |
#return {'response':answer}
|
| 45 |
-
|
|
|
|
| 46 |
|
| 47 |
except Exception as e:
|
| 48 |
print("Excepted")
|
|
|
|
| 26 |
for pkg in pkgs: print(pkg)
|
| 27 |
class Query(BaseModel):
|
| 28 |
smiles :List[str]
|
| 29 |
+
class PredictionResponse(BaseModel):
|
| 30 |
+
predictions: List[int]
|
| 31 |
rob_chem_model = ClassificationModel('roberta', 'BasselAhmed/RobertaChemClinToxTuned',use_cuda=False ,args={'evaluate_each_epoch':True , 'evaluate_during_training_verbose':True, 'seed':4})
|
| 32 |
|
| 33 |
+
@app.post("/ToxicityPrediction/")
|
| 34 |
+
def c(query:Query)->PredictionResponse:
|
| 35 |
print(query)
|
| 36 |
print(type(query))
|
| 37 |
query_dict = query.dict()
|
| 38 |
try:
|
| 39 |
predictions, raw_outputs = rob_chem_model.predict([str(query.smiles)])
|
| 40 |
print(predictions)
|
| 41 |
+
print(type({"predictions": predictions}))
|
| 42 |
#json_compatible_item_data = jsonable_encoder(predictions[0])
|
| 43 |
#return JSONResponse(content=json_compatible_item_data)
|
| 44 |
query_dict.update({"predictions":predictions})
|
| 45 |
+
print(query_dict)
|
| 46 |
+
print(type(query_dict))
|
| 47 |
#answer = {"prediction":predictions[0]}
|
| 48 |
#return {'response':answer}
|
| 49 |
+
|
| 50 |
+
return predictions
|
| 51 |
|
| 52 |
except Exception as e:
|
| 53 |
print("Excepted")
|