diff --git a/sdk/diffgram.egg-info/PKG-INFO b/sdk/diffgram.egg-info/PKG-INFO
new file mode 100644
index 0000000..83e04e9
--- /dev/null
+++ b/sdk/diffgram.egg-info/PKG-INFO
@@ -0,0 +1,65 @@
+Metadata-Version: 2.1
+Name: diffgram
+Version: 0.0.0
+Summary: SDK for Diffgram
+Home-page: https://github.com/diffgram/python-sdk
+Author: Diffgram
+Author-email: support@diffgram.com
+Classifier: Programming Language :: Python :: 3
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Description-Content-Type: text/markdown
+
+
+# SDK for Diffgram
+
+This is the SDK for [Diffgram](https://github.com/diffgram/diffgram)
and
+[Diffgram.com](https://diffgram.com/)
+
+## SDK Install
+
+#### [Full Documentation](https://diffgram.readme.io/docs)
+
+### Quickstart Install SDK
+`pip install diffgram`
+
+On linux
+`pip3 install diffgram`
+
+[Credentials Guide](https://diffgram.readme.io/reference)
+[Get Credentials from Diffgram.com](https://diffgram.com/) (or your Private Deploy)
+
+The starting point for most useful work is to get a project:
+```
+from diffgram import Project
+
+project = Project(host = "https://diffgram.com",
+ project_string_id = "replace_with_project_string",
+ client_id = "replace_with_client_id",
+ client_secret = "replace_with_client_secret")
+```
+
+Replace `host` with your URL for Open Core installs.
+
+* [Tasks Introduction](https://diffgram.readme.io/docs/tasks-introduction)
+* [Import Introduction](https://diffgram.readme.io/docs/importing-your-data)
+* [Updating Existing Instances](https://diffgram.readme.io/docs/importing-instances-walkthrough)
+* [Pre-Label Example Video](https://youtu.be/55Hofp1H7yM)
+* [Compatibility](https://diffgram.readme.io/docs/compatibility-will-diffgram-work-with-my-system)
+
+
+#### Beta
+Note the API/SDK is in beta and is undergoing rapid improvement. There may be breaking changes.
+Please see the [API docs](https://diffgram.readme.io/reference) for the latest canonical reference
+and be sure to upgrade to latest ie: `pip install diffgram --upgrade`. We will attempt to keep the SDK up to date with the API.
+
+[Help articles for Diffgram.com](https://diffgram.readme.io/) See below for some examples.
+
+Requires Python >=3.5
+
+The default install through pip will install dependencies
+for local prediction (tensorflow opencv) as listed in `requirements.txt`.
+The only requirement needed for majority of functions is `requests`.
+If you are looking for a minimal size install and already have requests use
+the `--no-dependencies` flag ie `pip install diffgram --no-dependencies`
+
diff --git a/sdk/diffgram.egg-info/SOURCES.txt b/sdk/diffgram.egg-info/SOURCES.txt
new file mode 100644
index 0000000..cbc17eb
--- /dev/null
+++ b/sdk/diffgram.egg-info/SOURCES.txt
@@ -0,0 +1,54 @@
+setup.py
+diffgram/__init__.py
+diffgram.egg-info/PKG-INFO
+diffgram.egg-info/SOURCES.txt
+diffgram.egg-info/dependency_links.txt
+diffgram.egg-info/requires.txt
+diffgram.egg-info/top_level.txt
+diffgram/brain/__init__.py
+diffgram/brain/brain.py
+diffgram/brain/inference.py
+diffgram/brain/instance.py
+diffgram/brain/train.py
+diffgram/convert/__init__.py
+diffgram/convert/convert.py
+diffgram/core/__init__.py
+diffgram/core/core.py
+diffgram/core/diffgram_dataset_iterator.py
+diffgram/core/directory.py
+diffgram/core/directory_samples.py
+diffgram/core/sliced_directory.py
+diffgram/export/__init__.py
+diffgram/export/export.py
+diffgram/file/__init__.py
+diffgram/file/file.py
+diffgram/file/file_3d.py
+diffgram/file/file_constructor.py
+diffgram/file/test_existing_instances.py
+diffgram/file/test_file.py
+diffgram/file/view.py
+diffgram/job/__init__.py
+diffgram/job/guide.py
+diffgram/job/job.py
+diffgram/label/__init__.py
+diffgram/label/label_new.py
+diffgram/label/test_label.py
+diffgram/member/__init__.py
+diffgram/models/__init__.py
+diffgram/models/base_model.py
+diffgram/models/model_interfaces.py
+diffgram/pytorch_diffgram/__init__.py
+diffgram/pytorch_diffgram/diffgram_pytorch_dataset.py
+diffgram/regular/__init__.py
+diffgram/regular/regular.py
+diffgram/role/Role.py
+diffgram/role/__init__.py
+diffgram/task/__init__.py
+diffgram/task/task.py
+diffgram/task/test_task.py
+diffgram/tensorflow_diffgram/__init__.py
+diffgram/tensorflow_diffgram/diffgram_tensorflow_dataset.py
+diffgram/tensorflow_diffgram/pytorch_test.py
+diffgram/utils/__init__.py
+diffgram/utils/visualization_utils.py
+tests/__init__.py
\ No newline at end of file
diff --git a/sdk/diffgram.egg-info/dependency_links.txt b/sdk/diffgram.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/sdk/diffgram.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/sdk/diffgram.egg-info/requires.txt b/sdk/diffgram.egg-info/requires.txt
new file mode 100644
index 0000000..2b53ab3
--- /dev/null
+++ b/sdk/diffgram.egg-info/requires.txt
@@ -0,0 +1,5 @@
+requests>=2.20.1
+scipy>=1.1.0
+six>=1.9.0
+pillow>=6.1.0
+imageio>=2.9.0
diff --git a/sdk/diffgram.egg-info/top_level.txt b/sdk/diffgram.egg-info/top_level.txt
new file mode 100644
index 0000000..34aeb02
--- /dev/null
+++ b/sdk/diffgram.egg-info/top_level.txt
@@ -0,0 +1,2 @@
+diffgram
+tests
diff --git a/sdk/diffgram/__init__.py b/sdk/diffgram/__init__.py
index 6c7afa0..d126c9c 100644
--- a/sdk/diffgram/__init__.py
+++ b/sdk/diffgram/__init__.py
@@ -5,3 +5,5 @@
from diffgram.core.core import Project
from diffgram.file.file import File
from diffgram.task.task import Task
+from diffgram.models.base_model import DiffgramBaseModel
+from diffgram.models.model_interfaces import DiffgramFile, Prediction, Attribute, Instance
diff --git a/sdk/diffgram/core/core.py b/sdk/diffgram/core/core.py
index d094def..c07f868 100644
--- a/sdk/diffgram/core/core.py
+++ b/sdk/diffgram/core/core.py
@@ -18,7 +18,6 @@
from diffgram.task.task import Task
from requests.auth import HTTPBasicAuth
-
class Project():
default_directory: Directory
last_response_header: None
diff --git a/sdk/diffgram/models/__init__.py b/sdk/diffgram/models/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/sdk/diffgram/models/base_model.py b/sdk/diffgram/models/base_model.py
new file mode 100644
index 0000000..d2ec39f
--- /dev/null
+++ b/sdk/diffgram/models/base_model.py
@@ -0,0 +1,70 @@
+from abc import ABC, abstractmethod
+from fastapi import HTTPException
+from typing import Literal
+from .model_interfaces import DiffgramFile, Prediction, Attribute, Instance
+class DiffgramBaseModel(ABC):
+ diffgram_allowed_types = Literal['image', 'frame', 'video', 'text', 'audio', 'sensor_fusion', 'geospatial']
+ allowed_types: list = None
+
+ def __init__(
+ self,
+ allowed_types: list = None,
+ ):
+ if allowed_types is not None:
+ if not isinstance(allowed_types, list):
+ raise ValueError('allowed_types must be of type list')
+
+ for allowed_type in allowed_types:
+ if allowed_type not in self.diffgram_allowed_types.__dict__['__args__']:
+ raise ValueError(f"{allowed_type} is not valid Diffgram file type")
+
+ self.allowed_types = allowed_types
+
+ @abstractmethod
+ def infere(self, file: DiffgramFile) -> Prediction:
+ raise NotImplementedError
+
+ @abstractmethod
+ def get_schema(self):
+ raise NotImplementedError
+
+ def serve(self, app):
+ @app.post("/infere")
+ async def infere_route(file: DiffgramFile):
+ if self.allowed_types is not None:
+ if file.type not in self.allowed_types:
+ raise HTTPException(status_code=404, detail=f"This model does not support {file.type} files")
+
+ predictions = self.infere(file)
+
+ if not isinstance(predictions, Prediction):
+ raise ValueError('predictions should be of type Prediction')
+
+ if predictions.instances:
+ for predicted_instance in predictions.instances:
+ instance = isinstance(predicted_instance, Instance)
+ if not instance:
+ raise ValueError('predicted instances should be of type Instance')
+
+ if predictions.attributes:
+ for predicted_attributes in predictions.attributes:
+ instance = isinstance(predicted_attributes, Attribute)
+ if not instance:
+ raise ValueError('predicted attributes should be of type Attribute')
+
+ return {
+ "file": file,
+ "predictions": predictions
+ }
+
+ @app.get("/get_schema")
+ async def get_schema_route():
+ return {
+ "message": "Get schema here"
+ }
+
+ @app.get("/ping")
+ async def ping_route():
+ return {
+ "message": "Model is up and running"
+ }
\ No newline at end of file
diff --git a/sdk/diffgram/models/model_interfaces.py b/sdk/diffgram/models/model_interfaces.py
new file mode 100644
index 0000000..eb59df0
--- /dev/null
+++ b/sdk/diffgram/models/model_interfaces.py
@@ -0,0 +1,37 @@
+from pydantic import BaseModel, AnyUrl, validator
+from typing import Optional, List, Literal
+
+class DiffgramImage(BaseModel):
+ height: int
+ width: int
+ url_signed: AnyUrl
+
+class DiffgramText(BaseModel):
+ tokens_url_signed: AnyUrl
+
+class DiffgramFile(BaseModel):
+ id: int
+ original_filename: str
+ image: Optional[DiffgramImage]
+ text: Optional[DiffgramText]
+ type: Literal['image', 'frame', 'video', 'text', 'audio', 'sensor_fusion', 'geospatial']
+
+ @validator('type')
+ def requre_object_if_type(cls, type, values):
+ file_object = values.get(type)
+
+ if not file_object:
+ raise ValueError(f"{type} is missing in the payload")
+
+ return type
+
+
+class Attribute(BaseModel):
+ id: int
+class Instance(BaseModel):
+ id: int
+
+class Prediction(BaseModel):
+ instances: Optional[List[Instance]]
+ attributes: Optional[List[Attribute]]
+
diff --git a/sdk/requirements.txt b/sdk/requirements.txt
index 651c49d..c96107c 100644
--- a/sdk/requirements.txt
+++ b/sdk/requirements.txt
@@ -5,4 +5,5 @@ six>=1.9.0
tensorflow>=1.12.0
pillow
torch
-imageio>=2.9.0
\ No newline at end of file
+imageio>=2.9.0
+fastapi>=0.85.0
\ No newline at end of file
diff --git a/sdk/samples/model_server.py b/sdk/samples/model_server.py
new file mode 100644
index 0000000..02c2dfa
--- /dev/null
+++ b/sdk/samples/model_server.py
@@ -0,0 +1,14 @@
+from diffgram import DiffgramBaseModel, Prediction, Instance, Attribute
+from fastapi import FastAPI
+class MyTestModel(DiffgramBaseModel):
+ def infere(self, file):
+ return Prediction(
+ instances=[Instance(id=1)],
+ attributes=[Attribute(id=1)]
+ )
+
+ def get_schema(self):
+ return super().get_schema()
+
+app = FastAPI()
+MyTestModel(allowed_types=["image", "audio"]).serve(app)
\ No newline at end of file