UdasriHasindu commited on
Commit ·
ac4efc7
1
Parent(s): 5345aa5
remove name from input fields
Browse files- README.md +1 -3
- routers/analyze_router.py +1 -5
- schema/patient_inputs.py +0 -4
- services/voice_analyze_service.py +2 -5
README.md
CHANGED
|
@@ -27,7 +27,6 @@ Submit a `multipart/form-data` POST request with:
|
|
| 27 |
|
| 28 |
| Field | Type | Description |
|
| 29 |
|-------|------|-------------|
|
| 30 |
-
| `name` | string | Patient name |
|
| 31 |
| `age` | int | Age (11–119) |
|
| 32 |
| `sex` | string | `male` or `female` |
|
| 33 |
| `test_time` | float | Time since recruitment (days) |
|
|
@@ -37,8 +36,7 @@ Submit a `multipart/form-data` POST request with:
|
|
| 37 |
|
| 38 |
```json
|
| 39 |
{
|
| 40 |
-
"prediction": 18.42
|
| 41 |
-
"patient": "John Doe"
|
| 42 |
}
|
| 43 |
```
|
| 44 |
|
|
|
|
| 27 |
|
| 28 |
| Field | Type | Description |
|
| 29 |
|-------|------|-------------|
|
|
|
|
| 30 |
| `age` | int | Age (11–119) |
|
| 31 |
| `sex` | string | `male` or `female` |
|
| 32 |
| `test_time` | float | Time since recruitment (days) |
|
|
|
|
| 36 |
|
| 37 |
```json
|
| 38 |
{
|
| 39 |
+
"prediction": 18.42
|
|
|
|
| 40 |
}
|
| 41 |
```
|
| 42 |
|
routers/analyze_router.py
CHANGED
|
@@ -9,7 +9,6 @@ router = APIRouter(
|
|
| 9 |
|
| 10 |
@router.post("/test")
|
| 11 |
async def test_endpoint(
|
| 12 |
-
name: str = Form(...),
|
| 13 |
age: int = Form(...),
|
| 14 |
sex: str = Form(...),
|
| 15 |
test_time: float = Form(...),
|
|
@@ -18,7 +17,6 @@ async def test_endpoint(
|
|
| 18 |
|
| 19 |
return {
|
| 20 |
"received_data": {
|
| 21 |
-
"name": name,
|
| 22 |
"age": age,
|
| 23 |
"sex": sex,
|
| 24 |
"test_time": test_time,
|
|
@@ -33,7 +31,6 @@ async def test_endpoint(
|
|
| 33 |
|
| 34 |
@router.post("/voice")
|
| 35 |
async def analyze_voice(
|
| 36 |
-
name: str = Form(..., min_length=1, max_length=100),
|
| 37 |
age: int = Form(..., gt=10, lt=120),
|
| 38 |
sex: str = Form(..., pattern="^(male|female)$"),
|
| 39 |
test_time: float = Form(..., gt=0),
|
|
@@ -42,7 +39,6 @@ async def analyze_voice(
|
|
| 42 |
# for debugging
|
| 43 |
print("-" * 20)
|
| 44 |
print("RECEIVED REQUEST FROM FRONTEND:")
|
| 45 |
-
print(f" Name: {name}")
|
| 46 |
print(f"Age: {age}")
|
| 47 |
print(f"Sex: {sex}")
|
| 48 |
print(f"Test Time: {test_time}")
|
|
@@ -59,7 +55,7 @@ async def analyze_voice(
|
|
| 59 |
|
| 60 |
print("-" * 20)
|
| 61 |
|
| 62 |
-
basic_info = {"age": age, "sex": sex, "
|
| 63 |
print(f"Basic info being passed to service: {basic_info}")
|
| 64 |
|
| 65 |
try:
|
|
|
|
| 9 |
|
| 10 |
@router.post("/test")
|
| 11 |
async def test_endpoint(
|
|
|
|
| 12 |
age: int = Form(...),
|
| 13 |
sex: str = Form(...),
|
| 14 |
test_time: float = Form(...),
|
|
|
|
| 17 |
|
| 18 |
return {
|
| 19 |
"received_data": {
|
|
|
|
| 20 |
"age": age,
|
| 21 |
"sex": sex,
|
| 22 |
"test_time": test_time,
|
|
|
|
| 31 |
|
| 32 |
@router.post("/voice")
|
| 33 |
async def analyze_voice(
|
|
|
|
| 34 |
age: int = Form(..., gt=10, lt=120),
|
| 35 |
sex: str = Form(..., pattern="^(male|female)$"),
|
| 36 |
test_time: float = Form(..., gt=0),
|
|
|
|
| 39 |
# for debugging
|
| 40 |
print("-" * 20)
|
| 41 |
print("RECEIVED REQUEST FROM FRONTEND:")
|
|
|
|
| 42 |
print(f"Age: {age}")
|
| 43 |
print(f"Sex: {sex}")
|
| 44 |
print(f"Test Time: {test_time}")
|
|
|
|
| 55 |
|
| 56 |
print("-" * 20)
|
| 57 |
|
| 58 |
+
basic_info = {"age": age, "sex": sex, "test_time": test_time}
|
| 59 |
print(f"Basic info being passed to service: {basic_info}")
|
| 60 |
|
| 61 |
try:
|
schema/patient_inputs.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
| 1 |
from pydantic import BaseModel, Field
|
| 2 |
from typing import Optional
|
| 3 |
|
| 4 |
-
class Patient(BaseModel):
|
| 5 |
-
id: Optional[int] = None
|
| 6 |
-
name: str
|
| 7 |
-
|
| 8 |
class BasicInfo(BaseModel):
|
| 9 |
age: int = Field(..., gt=10, lt=120)
|
| 10 |
sex: str = Field(..., example="male")
|
|
|
|
| 1 |
from pydantic import BaseModel, Field
|
| 2 |
from typing import Optional
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
class BasicInfo(BaseModel):
|
| 5 |
age: int = Field(..., gt=10, lt=120)
|
| 6 |
sex: str = Field(..., example="male")
|
services/voice_analyze_service.py
CHANGED
|
@@ -13,10 +13,7 @@ async def process_audio_and_predict(audio_file, basic_info):
|
|
| 13 |
try:
|
| 14 |
voice_features = extract_voice_features(temp_file_path)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
# exclude name
|
| 19 |
-
prediction_features = {k: v for k, v in basic_info.items() if k != 'name'}
|
| 20 |
|
| 21 |
# Encode sex: male=1, female=0
|
| 22 |
if 'sex' in prediction_features:
|
|
@@ -27,7 +24,7 @@ async def process_audio_and_predict(audio_file, basic_info):
|
|
| 27 |
print("CALLING ML MODEL...")
|
| 28 |
prediction = predict_parkinson(feature_data)
|
| 29 |
|
| 30 |
-
final_result = {"prediction": prediction
|
| 31 |
print(f"FINAL RESULT: {final_result}")
|
| 32 |
|
| 33 |
return final_result
|
|
|
|
| 13 |
try:
|
| 14 |
voice_features = extract_voice_features(temp_file_path)
|
| 15 |
|
| 16 |
+
prediction_features = basic_info.copy()
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Encode sex: male=1, female=0
|
| 19 |
if 'sex' in prediction_features:
|
|
|
|
| 24 |
print("CALLING ML MODEL...")
|
| 25 |
prediction = predict_parkinson(feature_data)
|
| 26 |
|
| 27 |
+
final_result = {"prediction": prediction}
|
| 28 |
print(f"FINAL RESULT: {final_result}")
|
| 29 |
|
| 30 |
return final_result
|