Closed camenduru closed 1 year ago
from typing import List
from typing import Any
from dataclasses import dataclass
import json
@dataclass
class Creator:
username: str
image: str
@staticmethod
def from_dict(obj: Any) -> 'Creator':
_username = str(obj.get("username"))
_image = str(obj.get("image"))
return Creator(_username, _image)
@dataclass
class File:
name: str
id: int
sizeKB: float
type: str
format: str
pickleScanResult: str
pickleScanMessage: str
virusScanResult: str
scannedAt: str
hashes: Hashes
downloadUrl: str
@staticmethod
def from_dict(obj: Any) -> 'File':
_name = str(obj.get("name"))
_id = int(obj.get("id"))
_sizeKB = float(obj.get("sizeKB"))
_type = str(obj.get("type"))
_format = str(obj.get("format"))
_pickleScanResult = str(obj.get("pickleScanResult"))
_pickleScanMessage = str(obj.get("pickleScanMessage"))
_virusScanResult = str(obj.get("virusScanResult"))
_scannedAt = str(obj.get("scannedAt"))
_hashes = Hashes.from_dict(obj.get("hashes"))
_downloadUrl = str(obj.get("downloadUrl"))
return File(_name, _id, _sizeKB, _type, _format, _pickleScanResult, _pickleScanMessage, _virusScanResult, _scannedAt, _hashes, _downloadUrl)
@dataclass
class Hashes:
AutoV1: str
AutoV2: str
SHA256: str
CRC32: str
BLAKE3: str
@staticmethod
def from_dict(obj: Any) -> 'Hashes':
_AutoV1 = str(obj.get("AutoV1"))
_AutoV2 = str(obj.get("AutoV2"))
_SHA256 = str(obj.get("SHA256"))
_CRC32 = str(obj.get("CRC32"))
_BLAKE3 = str(obj.get("BLAKE3"))
return Hashes(_AutoV1, _AutoV2, _SHA256, _CRC32, _BLAKE3)
@dataclass
class Image:
url: str
nsfw: bool
width: int
height: int
hash: str
meta: Meta
generationProcess: str
tags: List[object]
@staticmethod
def from_dict(obj: Any) -> 'Image':
_url = str(obj.get("url"))
_nsfw =
_width = int(obj.get("width"))
_height = int(obj.get("height"))
_hash = str(obj.get("hash"))
_meta = Meta.from_dict(obj.get("meta"))
_generationProcess = str(obj.get("generationProcess"))
_tags = [.from_dict(y) for y in obj.get("tags")]
return Image(_url, _nsfw, _width, _height, _hash, _meta, _generationProcess, _tags)
@dataclass
class Item:
id: int
name: str
description: str
type: str
poi: bool
nsfw: bool
allowNoCredit: bool
allowCommercialUse: str
allowDerivatives: bool
allowDifferentLicense: bool
creator: Creator
tags: List[str]
modelVersions: List[ModelVersion]
@staticmethod
def from_dict(obj: Any) -> 'Item':
_id = int(obj.get("id"))
_name = str(obj.get("name"))
_description = str(obj.get("description"))
_type = str(obj.get("type"))
_poi =
_nsfw =
_allowNoCredit =
_allowCommercialUse = str(obj.get("allowCommercialUse"))
_allowDerivatives =
_allowDifferentLicense =
_creator = Creator.from_dict(obj.get("creator"))
_tags = [.from_dict(y) for y in obj.get("tags")]
_modelVersions = [ModelVersion.from_dict(y) for y in obj.get("modelVersions")]
return Item(_id, _name, _description, _type, _poi, _nsfw, _allowNoCredit, _allowCommercialUse, _allowDerivatives, _allowDifferentLicense, _creator, _tags, _modelVersions)
@dataclass
class Meta:
ENSD: str
Size: str
seed: object
Model: str
steps: int
prompt: str
sampler: str
cfgScale: float
Model hash: str
negativePrompt: str
Face restoration: str
resources: List[Resource]
Batch pos: str
Batch size: str
Hires upscale: str
Hires upscaler: str
Denoising strength: str
Hires steps: str
Mask blur: str
Conditional mask weight: str
Clip skip: str
SD upscale overlap: str
SD upscale upscaler: str
First pass size: str
@staticmethod
def from_dict(obj: Any) -> 'Meta':
_ENSD = str(obj.get("ENSD"))
_Size = str(obj.get("Size"))
_seed =
_Model = str(obj.get("Model"))
_steps = int(obj.get("steps"))
_prompt = str(obj.get("prompt"))
_sampler = str(obj.get("sampler"))
_cfgScale = float(obj.get("cfgScale"))
_Model hash = str(obj.get("Model hash"))
_negativePrompt = str(obj.get("negativePrompt"))
_Face restoration = str(obj.get("Face restoration"))
_resources = [Resource.from_dict(y) for y in obj.get("resources")]
_Batch pos = str(obj.get("Batch pos"))
_Batch size = str(obj.get("Batch size"))
_Hires upscale = str(obj.get("Hires upscale"))
_Hires upscaler = str(obj.get("Hires upscaler"))
_Denoising strength = str(obj.get("Denoising strength"))
_Hires steps = str(obj.get("Hires steps"))
_Mask blur = str(obj.get("Mask blur"))
_Conditional mask weight = str(obj.get("Conditional mask weight"))
_Clip skip = str(obj.get("Clip skip"))
_SD upscale overlap = str(obj.get("SD upscale overlap"))
_SD upscale upscaler = str(obj.get("SD upscale upscaler"))
_First pass size = str(obj.get("First pass size"))
return Meta(_ENSD, _Size, _seed, _Model, _steps, _prompt, _sampler, _cfgScale, _Model hash, _negativePrompt, _Face restoration, _resources, _Batch pos, _Batch size, _Hires upscale, _Hires upscaler, _Denoising strength, _Hires steps, _Mask blur, _Conditional mask weight, _Clip skip, _SD upscale overlap, _SD upscale upscaler, _First pass size)
@dataclass
class Metadata:
totalItems: int
currentPage: int
pageSize: int
totalPages: int
nextPage: str
@staticmethod
def from_dict(obj: Any) -> 'Metadata':
_totalItems = int(obj.get("totalItems"))
_currentPage = int(obj.get("currentPage"))
_pageSize = int(obj.get("pageSize"))
_totalPages = int(obj.get("totalPages"))
_nextPage = str(obj.get("nextPage"))
return Metadata(_totalItems, _currentPage, _pageSize, _totalPages, _nextPage)
@dataclass
class ModelVersion:
id: int
modelId: int
name: str
createdAt: str
updatedAt: str
trainedWords: List[str]
baseModel: str
earlyAccessTimeFrame: int
description: str
files: List[File]
images: List[Image]
downloadUrl: str
@staticmethod
def from_dict(obj: Any) -> 'ModelVersion':
_id = int(obj.get("id"))
_modelId = int(obj.get("modelId"))
_name = str(obj.get("name"))
_createdAt = str(obj.get("createdAt"))
_updatedAt = str(obj.get("updatedAt"))
_trainedWords = [.from_dict(y) for y in obj.get("trainedWords")]
_baseModel = str(obj.get("baseModel"))
_earlyAccessTimeFrame = int(obj.get("earlyAccessTimeFrame"))
_description = str(obj.get("description"))
_files = [File.from_dict(y) for y in obj.get("files")]
_images = [Image.from_dict(y) for y in obj.get("images")]
_downloadUrl = str(obj.get("downloadUrl"))
return ModelVersion(_id, _modelId, _name, _createdAt, _updatedAt, _trainedWords, _baseModel, _earlyAccessTimeFrame, _description, _files, _images, _downloadUrl)
@dataclass
class Resource:
hash: str
name: str
type: str
@staticmethod
def from_dict(obj: Any) -> 'Resource':
_hash = str(obj.get("hash"))
_name = str(obj.get("name"))
_type = str(obj.get("type"))
return Resource(_hash, _name, _type)
@dataclass
class Root:
items: List[Item]
metadata: Metadata
@staticmethod
def from_dict(obj: Any) -> 'Root':
_items = [Item.from_dict(y) for y in obj.get("items")]
_metadata = Metadata.from_dict(obj.get("metadata"))
return Root(_items, _metadata)
# Example Usage
# jsonstring = json.loads(myjsonstring)
# root = Root.from_dict(jsonstring)
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "model"
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "Model",
"type": "Pruned Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Config",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "model"
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "VAE",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "VAE",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "VAE",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "VAE",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Checkpoint",
"type": "Model",
"type": "VAE",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "VAE",
"type": "Model",
"type": "Model",
"type": "VAE",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "VAE",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "VAE",
"type": "Checkpoint",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Pruned Model",
"type": "Model",
"type": "Pruned Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "Model",
"type": "Model",
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "model"
"type": "model"
"type": "TextualInversion",
"type": "Model",
"type": "Model",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Pruned Model",
"type": "hypernet",
"type": "Model",
"type": "LORA",
"type": "Model",
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "lora",
"type": "Model",
"type": "lora",
"type": "lora",
"type": "Model",
"type": "lora",
"type": "lora",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "model"
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Checkpoint",
"type": "Config",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Config",
"type": "Model",
"type": "Pruned Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "LORA",
"type": "Model",
"type": "LORA",
"type": "Model",
"type": "model"
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "Model",
"type": "model"
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "model"
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "Model",
"type": "model"
"type": "lora",
"type": "lora",
"type": "model"
"type": "lora",
"type": "model"
"type": "lora",
"type": "lora",
"type": "lora",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "VAE",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "LORA",
"type": "Model",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Model",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Hypernetwork",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "VAE",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "Model",
"type": "Pruned Model",
"type": "Checkpoint",
"type": "Model",
"type": "TextualInversion",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "LORA",
"type": "Model",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "Model",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "Checkpoint",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Pruned Model",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "lora",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Config",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Config",
"type": "Model",
"type": "Model",
"type": "Config",
"type": "Model",
"type": "TextualInversion",
"type": "Model",
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "Pruned Model",
"type": "Pruned Model",
"type": "model"
"type": "Checkpoint",
"type": "Model",
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "model"
"type": "Checkpoint",
"type": "Model",
"type": "Model",
"type": "LORA",
"type": "Model",
"type": "model"
"type": "lora",
"type": "model"
"type": "lora",
"type": "model"
"type": "lora",
"type": "model"
"type": "lora",
"type": "model"
"type": "lora",
"type": "model"
"type": "lora",
"type": "Checkpoint",
"type": "Model",
"type": "Model",