-
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Alpha version completed (#4)
Hotfix for release action
- Loading branch information
1 parent
affe78e
commit ef64682
Showing
205 changed files
with
20,902 additions
and
1,694 deletions.
There are no files selected for viewing
File renamed without changes.
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 |
---|---|---|
|
@@ -86,4 +86,4 @@ typings/ | |
.webpack/ | ||
|
||
# Electron-Forge | ||
out/ | ||
out/ |
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 was deleted.
Oops, something went wrong.
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,38 +1,41 @@ | ||
from typing import Callable, Dict | ||
|
||
from .node_base import NodeBase | ||
|
||
from sanic.log import logger | ||
|
||
|
||
# Implementation based on https://medium.com/@geoffreykoh/implementing-the-factory-pattern-via-dynamic-registry-and-python-decorators-479fc1537bbe | ||
class NodeFactory: | ||
"""The factory class for creating nodes""" | ||
|
||
registry = {} | ||
""" Internal registry for available nodes """ | ||
|
||
@classmethod | ||
def create_node(cls, category: str, name: str) -> NodeBase: | ||
"""Factory command to create the node""" | ||
|
||
node_class = cls.registry[category][name] | ||
node = node_class() | ||
logger.info(f"Created {category}, {name} node") | ||
return node | ||
|
||
@classmethod | ||
def register(cls, category: str, name: str) -> Callable: | ||
def inner_wrapper(wrapped_class: NodeBase) -> Callable: | ||
if category not in cls.registry: | ||
cls.registry[category] = {} | ||
if name in cls.registry[category]: | ||
logger.warning(f"Node {name} already exists. Will replace it") | ||
cls.registry[category][name] = wrapped_class | ||
return wrapped_class | ||
|
||
return inner_wrapper | ||
|
||
@classmethod | ||
def get_registry(cls) -> Dict: | ||
return cls.registry | ||
import sys | ||
from typing import Callable, Dict | ||
|
||
sys.path.append("..") | ||
|
||
from sanic_server.sanic.log import logger | ||
|
||
from .node_base import NodeBase | ||
|
||
|
||
# Implementation based on https://medium.com/@geoffreykoh/implementing-the-factory-pattern-via-dynamic-registry-and-python-decorators-479fc1537bbe | ||
class NodeFactory: | ||
"""The factory class for creating nodes""" | ||
|
||
registry = {} | ||
""" Internal registry for available nodes """ | ||
|
||
@classmethod | ||
def create_node(cls, category: str, name: str) -> NodeBase: | ||
"""Factory command to create the node""" | ||
|
||
node_class = cls.registry[category][name] | ||
node = node_class() | ||
logger.info(f"Created {category}, {name} node") | ||
return node | ||
|
||
@classmethod | ||
def register(cls, category: str, name: str) -> Callable: | ||
def inner_wrapper(wrapped_class: NodeBase) -> Callable: | ||
if category not in cls.registry: | ||
cls.registry[category] = {} | ||
if name in cls.registry[category]: | ||
logger.warning(f"Node {name} already exists. Will replace it") | ||
cls.registry[category][name] = wrapped_class | ||
return wrapped_class | ||
|
||
return inner_wrapper | ||
|
||
@classmethod | ||
def get_registry(cls) -> Dict: | ||
return cls.registry |
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,62 +1,67 @@ | ||
from typing import Dict, List | ||
|
||
from .generic_inputs import DropDownInput | ||
|
||
|
||
def FileInput( | ||
input_type: str, label: str, accepts: List[str], filetypes: List[str] | ||
) -> Dict: | ||
""" Input for submitting a local file """ | ||
return { | ||
"type": f"file::{input_type}", | ||
"label": label, | ||
"accepts": None, | ||
"filetypes": filetypes, | ||
} | ||
|
||
|
||
def ImageFileInput() -> Dict: | ||
""" Input for submitting a local image file """ | ||
return FileInput( | ||
"image", "Image File", None, ["png", "jpg", "jpeg", "gif", "tiff", "webp"] | ||
) | ||
|
||
|
||
def PthFileInput() -> Dict: | ||
""" Input for submitting a local .pth file """ | ||
return FileInput("pth", "Pretrained Model", None, ["pth"]) | ||
|
||
|
||
def DirectoryInput() -> Dict: | ||
""" Input for submitting a local directory """ | ||
return FileInput("directory", "Directory", None, ["directory"]) | ||
|
||
|
||
def ImageExtensionDropdown() -> Dict: | ||
""" Input for selecting file type from dropdown """ | ||
return DropDownInput( | ||
"image-extensions", | ||
"Image Extension", | ||
[ | ||
{ | ||
"option": "PNG", | ||
"value": "png", | ||
}, | ||
{ | ||
"option": "JPG", | ||
"value": "jpg", | ||
}, | ||
{ | ||
"option": "GIF", | ||
"value": "gif", | ||
}, | ||
{ | ||
"option": "TIFF", | ||
"value": "tiff", | ||
}, | ||
{ | ||
"option": "WEBP", | ||
"value": "webp", | ||
}, | ||
], | ||
) | ||
from typing import Dict, List | ||
|
||
from .generic_inputs import DropDownInput | ||
|
||
|
||
def FileInput( | ||
input_type: str, label: str, accepts: List[str], filetypes: List[str] | ||
) -> Dict: | ||
""" Input for submitting a local file """ | ||
return { | ||
"type": f"file::{input_type}", | ||
"label": label, | ||
"accepts": None, | ||
"filetypes": filetypes, | ||
} | ||
|
||
|
||
def ImageFileInput() -> Dict: | ||
""" Input for submitting a local image file """ | ||
return FileInput( | ||
"image", "Image File", None, ["png", "jpg", "jpeg", "gif", "tiff", "webp"] | ||
) | ||
|
||
|
||
def PthFileInput() -> Dict: | ||
""" Input for submitting a local .pth file """ | ||
return FileInput("pth", "Pretrained Model", None, ["pth"]) | ||
|
||
|
||
def TorchFileInput() -> Dict: | ||
""" Input for submitting a local .pth or .pt file """ | ||
return FileInput("pth", "Pretrained Model", None, ["pth", "pt"]) | ||
|
||
|
||
def DirectoryInput() -> Dict: | ||
""" Input for submitting a local directory """ | ||
return FileInput("directory", "Directory", None, ["directory"]) | ||
|
||
|
||
def ImageExtensionDropdown() -> Dict: | ||
""" Input for selecting file type from dropdown """ | ||
return DropDownInput( | ||
"image-extensions", | ||
"Image Extension", | ||
[ | ||
{ | ||
"option": "PNG", | ||
"value": "png", | ||
}, | ||
{ | ||
"option": "JPG", | ||
"value": "jpg", | ||
}, | ||
{ | ||
"option": "GIF", | ||
"value": "gif", | ||
}, | ||
{ | ||
"option": "TIFF", | ||
"value": "tiff", | ||
}, | ||
{ | ||
"option": "WEBP", | ||
"value": "webp", | ||
}, | ||
], | ||
) |
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.