Spaces:
Running
Running
Update structure.py
Browse files- structure.py +20 -18
structure.py
CHANGED
|
@@ -1,18 +1,20 @@
|
|
| 1 |
-
from pydantic import BaseModel, Field
|
| 2 |
-
from typing import List
|
| 3 |
-
|
| 4 |
-
class PredictionEntry(BaseModel):
|
| 5 |
-
model: str = Field(..., description="Name of the model used for prediction")
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
from pydantic import BaseModel, Field
|
| 2 |
+
from typing import List
|
| 3 |
+
|
| 4 |
+
class PredictionEntry(BaseModel):
|
| 5 |
+
model: str = Field(..., description="Name of the model used for prediction")
|
| 6 |
+
error: str | None = Field(None, description="Error message if prediction failed")
|
| 7 |
+
predicted_class: int = Field(..., description="Predicted class index")
|
| 8 |
+
confidence: float = Field(..., ge=-100.0, le=1.0, description="Prediction confidence (0-1)")
|
| 9 |
+
|
| 10 |
+
class ImagePredictionResponse(BaseModel):
|
| 11 |
+
predictions: List[PredictionEntry] = Field(..., description="List of predictions with model, class, and confidence")
|
| 12 |
+
|
| 13 |
+
class TextPredictionRequest(BaseModel):
|
| 14 |
+
text: str = Field(..., example="This is a sample text to classify")
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class TextPredictionResponse(BaseModel):
|
| 18 |
+
predicted_class: str = Field(..., description="Predicted label: 'AI' or 'Human'")
|
| 19 |
+
confidence_ai: float = Field(..., ge=-100.0, le=1.0, description="Confidence score for AI (0-1)")
|
| 20 |
+
confidence_human: float = Field(..., ge=-100.0, le=1.0, description="Confidence score for Human (0-1)")
|