-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from enoch3712/classificationStrategies
Classification strategies
- Loading branch information
Showing
10 changed files
with
314 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
from typing import Any, Optional | ||
from pydantic import BaseModel | ||
from extract_thinker.models.contract import Contract | ||
import os | ||
|
||
|
||
class Classification(BaseModel): | ||
name: str | ||
description: str | ||
contract: Optional[Contract] = None | ||
image: Optional[str] = None # Path to the image file | ||
extractor: Optional[Any] = None | ||
|
||
def set_image(self, image_path: str): | ||
if os.path.isfile(image_path): | ||
self.image = image_path | ||
else: | ||
raise ValueError(f"The provided string '{image_path}' is not a valid file path.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from pydantic import BaseModel | ||
from typing import Optional | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class ClassificationResponse(BaseModel): | ||
name: str | ||
confidence: Optional[int] = Field("From 1 to 10. 10 being the highest confidence. Always integer", ge=1, le=10) | ||
|
||
def __hash__(self): | ||
return hash((self.name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.