python_code
stringlengths
0
869k
import os import uuid from typing import Dict, List, Optional from grpc._channel import _InactiveRpcError from qdrant_client.http.exceptions import UnexpectedResponse from qdrant_client.http.models import PayloadSchemaType from datastore.datastore import DataStore from models.models import ( DocumentChunk, Do...
import os from typing import Any, List from datetime import datetime from supabase import Client from datastore.providers.pgvector_datastore import PGClient, PgVectorDataStore from models.models import ( DocumentMetadataFilter, ) SUPABASE_URL = os.environ.get("SUPABASE_URL") assert SUPABASE_URL is not None, "SUP...
import asyncio import os import re import time import base64 from typing import Dict, List, Optional, Union from datastore.datastore import DataStore from models.models import DocumentChunk, DocumentChunkMetadata, DocumentChunkWithScore, DocumentMetadataFilter, Query, QueryResult, QueryWithEmbedding from loguru import ...
import os from typing import Dict, List, Any, Optional import elasticsearch from elasticsearch import Elasticsearch, helpers from loguru import logger from datastore.datastore import DataStore from models.models import ( DocumentChunk, DocumentChunkWithScore, DocumentMetadataFilter, QueryResult, Q...
import os from typing import Any, Dict, List, Optional import pinecone from tenacity import retry, wait_random_exponential, stop_after_attempt import asyncio from loguru import logger from datastore.datastore import DataStore from models.models import ( DocumentChunk, DocumentChunkMetadata, DocumentChunkWi...
import os from typing import Any, List from datetime import datetime import numpy as np from psycopg2 import connect from psycopg2.extras import DictCursor from pgvector.psycopg2 import register_vector from services.date import to_unix_timestamp from datastore.providers.pgvector_datastore import PGClient, PgVectorDat...
import json import os import asyncio from loguru import logger from typing import Dict, List, Optional from pymilvus import ( Collection, connections, utility, FieldSchema, DataType, CollectionSchema, MilvusException, ) from uuid import uuid4 from services.date import to_unix_timestamp fr...
# This is a version of the main.py file found in ../../server/main.py that also gives ChatGPT access to the upsert endpoint # (allowing it to save information from the chat back to the vector) database. # Copy and paste this into the main file at ../../server/main.py if you choose to give the model access to the upsert...
# This is a version of the main.py file found in ../../../server/main.py without authentication. # Copy and paste this into the main file at ../../../server/main.py if you choose to use no authentication for your retrieval plugin. from typing import Optional import uvicorn from fastapi import FastAPI, File, Form, HTTPE...
import uuid import json import argparse import asyncio from loguru import logger from models.models import Document, DocumentMetadata from datastore.datastore import DataStore from datastore.factory import get_datastore from services.extract_metadata import extract_metadata_from_document from services.pii_detection im...
import uuid import json import argparse import asyncio from loguru import logger from models.models import Document, DocumentMetadata from datastore.datastore import DataStore from datastore.factory import get_datastore from services.extract_metadata import extract_metadata_from_document from services.pii_detection im...
import uuid import zipfile import os import json import argparse import asyncio from loguru import logger from models.models import Document, DocumentMetadata, Source from datastore.datastore import DataStore from datastore.factory import get_datastore from services.extract_metadata import extract_metadata_from_docume...
from models.models import Source from services.openai import get_chat_completion import json from typing import Dict import os from loguru import logger def extract_metadata_from_document(text: str) -> Dict[str, str]: sources = Source.__members__.keys() sources_string = ", ".join(sources) # This prompt is ...
import os from services.openai import get_chat_completion def screen_text_for_pii(text: str) -> bool: # This prompt is just an example, change it to fit your use case messages = [ { "role": "system", "content": f""" You can only respond with the word "True" or "Fals...
import os from io import BufferedReader from typing import Optional from fastapi import UploadFile import mimetypes from PyPDF2 import PdfReader import docx2txt import csv import pptx from loguru import logger from models.models import Document, DocumentMetadata async def get_document_from_file( file: UploadFile...
from typing import List import openai import os from loguru import logger from tenacity import retry, wait_random_exponential, stop_after_attempt @retry(wait=wait_random_exponential(min=1, max=20), stop=stop_after_attempt(3)) def get_embeddings(texts: List[str]) -> List[List[float]]: """ Embed texts using Op...
import arrow from loguru import logger def to_unix_timestamp(date_str: str) -> int: """ Convert a date string to a unix timestamp (seconds since epoch). Args: date_str: The date string to convert. Returns: The unix timestamp corresponding to the date string. If the date string c...
from typing import Dict, List, Optional, Tuple import uuid import os from models.models import Document, DocumentChunk, DocumentChunkMetadata import tiktoken from services.openai import get_embeddings # Global variables tokenizer = tiktoken.get_encoding( "cl100k_base" ) # The encoding scheme to use for tokeniza...
from setuptools import setup, find_packages setup( name="neuron_explainer", packages=find_packages(), version="0.0.1", author="OpenAI", install_requires=[ "httpx>=0.22", "scikit-learn", "boostedblob>=0.13.0", "tiktoken", "blobfile", "numpy", "...
def standardize_azure_url(url): """Make sure url is converted to url format, not an azure path""" if url.startswith("az://openaipublic/"): url = url.replace("az://openaipublic/", "https://openaipublic.blob.core.windows.net/") return url
import asyncio import contextlib import os import random import traceback from asyncio import Semaphore from functools import wraps from typing import Any, Callable, Optional import httpx import orjson def is_api_error(err: Exception) -> bool: if isinstance(err, httpx.HTTPStatusError): response = err.res...
"""Utilities for formatting activation records into prompts.""" import math from typing import Optional, Sequence from neuron_explainer.activations.activations import ActivationRecord UNKNOWN_ACTIVATION_STRING = "unknown" def relu(x: float) -> float: return max(0.0, x) def calculate_max_activation(activation...
# Dataclasses and enums for storing neuron-indexed information about activations. Also, related # helper functions. import math from dataclasses import dataclass, field from typing import List, Optional, Union import urllib.request import blobfile as bf import boostedblob as bbb from neuron_explainer.fast_dataclasses...
from dataclasses import dataclass from typing import List, Union import blobfile as bf from neuron_explainer.fast_dataclasses import FastDataclass, loads, register_dataclass from neuron_explainer.azure import standardize_azure_url import urllib.request @register_dataclass @dataclass class TokensAndWeights(FastDatacl...
from neuron_explainer.explanations.few_shot_examples import FewShotExampleSet from neuron_explainer.explanations.prompt_builder import HarmonyMessage, PromptFormat, Role from neuron_explainer.explanations.simulator import ( ExplanationNeuronSimulator, ExplanationTokenByTokenSimulator, ) def test_make_explanat...
import json import os from dataclasses import dataclass from neuron_explainer.activations.activations import ActivationRecord @dataclass(frozen=True) class Puzzle: """A puzzle is a ground truth explanation, a collection of sentences (stored as ActivationRecords) with activations according to that explanation...
from __future__ import annotations from enum import Enum from typing import TypedDict, Union import tiktoken HarmonyMessage = TypedDict( "HarmonyMessage", { "role": str, "content": str, }, ) class PromptFormat(str, Enum): """ Different ways of formatting the components of a prom...
"""Uses API calls to generate explanations of neuron behavior.""" from __future__ import annotations import logging import re from abc import ABC, abstractmethod from enum import Enum from typing import Any, Optional, Sequence, Union from neuron_explainer.activations.activation_records import ( calculate_max_act...
# Dataclasses and enums for storing neuron explanations, their scores, and related data. Also, # related helper functions. from __future__ import annotations import json from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import blobfile as bf import boostedblob as bbb fr...
from __future__ import annotations import asyncio import logging from typing import Any, Callable, Coroutine, Sequence import numpy as np from neuron_explainer.activations.activations import ActivationRecord from neuron_explainer.explanations.calibrated_simulator import ( CalibratedNeuronSimulator, LinearCali...
from dataclasses import dataclass from enum import Enum from typing import List from neuron_explainer.fast_dataclasses import FastDataclass @dataclass class Example(FastDataclass): """ An example list of tokens as strings corresponding to top token space inputs of a neuron, with a string explanation of t...
""" Code for calibrating simulations of neuron behavior. Calibration refers to a process of mapping from a space of predicted activation values (e.g. [0, 10]) to the real activation distribution for a neuron. See http://go/neuron_explanation_methodology for description of calibration step. Necessary for simulating neu...
import asyncio from typing import Any from neuron_explainer.explanations.explainer import ( TokenActivationPairExplainer, TokenSpaceRepresentationExplainer, ) from neuron_explainer.explanations.few_shot_examples import TEST_EXAMPLES, FewShotExampleSet from neuron_explainer.explanations.prompt_builder import Ha...
# Few-shot examples for generating and simulating neuron explanations. from __future__ import annotations from dataclasses import dataclass from enum import Enum from typing import List, Optional from neuron_explainer.activations.activations import ActivationRecord from neuron_explainer.fast_dataclasses import FastD...
"""Uses API calls to simulate neuron activations based on an explanation.""" from __future__ import annotations import asyncio import logging from abc import ABC, abstractmethod from collections import OrderedDict from enum import Enum from typing import Any, Optional, Sequence, Union import numpy as np from neuron_...
# Utilities for dataclasses that are very fast to serialize and deserialize, with limited data # validation. Fields must not be tuples, since they get serialized and then deserialized as lists. # # The unit tests for this library show how to use it. import json from dataclasses import dataclass, field, fields, is_data...
from .fast_dataclasses import FastDataclass, dumps, loads, register_dataclass __all__ = ["FastDataclass", "dumps", "loads", "register_dataclass"]
from dataclasses import dataclass import pytest from .fast_dataclasses import FastDataclass, dumps, loads, register_dataclass # Inheritance is a bit tricky with our setup. dataclass_name must be set for instances of these # classes to serialize and deserialize correctly, but if it's given a default value, then subc...
# %% import logging from flask import Flask, request from flask_cors import CORS import json import urllib.request def load_az_json(url): with urllib.request.urlopen(url) as f: return json.load(f) def start( dev: bool = False, host_name: str = "0.0.0.0", port: int = 80, ): app = Flask("...
import multiprocessing import os import sys import subprocess from distutils import sysconfig from distutils.command.build import build as DistutilsBuild from setuptools import setup def build_common(dynamic_library_extension, cmake_arg_list=None): # On OSX CMake's FindPythonLibs is flaky; we need to supply lib a...
from doom_py.vizdoom import * import os class Loader(): """ This class converts file name to full paths to be imported by the DoomGame """ def get_vizdoom_path(self): package_directory = os.path.dirname(os.path.abspath(__file__)) return os.path.join(package_directory, 'bin/vizdoom')...
#!/usr/bin/python ##################################################################### # This script presents how to run some scenarios. # Configuration is loaded from "../../examples/config/<SCENARIO_NAME>.cfg" file. # <episodes> number of episodes are played. # Random combination of buttons is chosen for every act...
#!/usr/bin/python ##################################################################### # This script presents how to make use of game variables to implement # shaping using health_guided.wad scenario # Health_guided scenario is just like health_gathering # (see "../../scenarios/README.md") but for each collected med...
#!/usr/bin/python from __future__ import print_function from vizdoom import * from random import choice from time import sleep from time import time game = DoomGame() game.set_vizdoom_path("../../bin/vizdoom") game.set_doom_game_path("../../scenarios/freedoom2.wad") #game.set_doom_game_path("../../scenarios/doom2...
#!/usr/bin/python ##################################################################### # This script presents SPECTATOR mode. In SPECTATOR mode you play and # your agent can learn from it. # Configuration is loaded from "../../examples/config/<SCENARIO_NAME>.cfg" file. # # To see the scenario description go to "../....
#!/usr/bin/python ##################################################################### # This script tests performance in frames per second. # Change iters, resolution, window visibility, use get_ state or not. # It should give you some idea how fast the framework can work on # your hardware. The test involes copying...
#!/usr/bin/python ##################################################################### # This script presents different formats of the screen buffer. # OpenCV is used here to display images, install it or remove any # references to cv2 # Configuration is loaded from "../../examples/config/basic.cfg" file. # <episodes>...
#!/usr/bin/python ##################################################################### # This script presents how to run deterministic episodes by setting # seed. After setting the seed every episode will look the same (if # agent will behave deterministicly of course). # Configuration is loaded from "../../examples...
#!/usr/bin/python ##################################################################### # This script presents how to use the most basic features of the environment. # It configures the engine, and makes the agent perform random actions. # It also gets current state and reward earned with the action. # <episodes> numbe...
#!/usr/bin/python from __future__ import print_function from vizdoom import * from random import choice game = DoomGame() game.set_vizdoom_path("../../bin/vizdoom") # Use CIG example config or Your own. game.load_config("../../examples/config/cig.cfg") # Select game and map You want to use. game.set_doom_game_path...
#!/usr/bin/python from __future__ import print_function from vizdoom import * from random import choice game = DoomGame() # Use CIG example config or Your own. game.load_config("../../examples/config/cig.cfg") # Select game and map You want to use. game.set_doom_game_path("../../scenarios/freedoom2.wad") #game.set_...
#!/usr/bin/python import itertools as it import pickle from random import sample, randint, random from time import time from vizdoom import * import cv2 import numpy as np import theano from lasagne.init import GlorotUniform, Constant from lasagne.layers import Conv2DLayer, InputLayer, DenseLayer, MaxPool2DLayer, get...
#!/usr/bin/python from __future__ import print_function from vizdoom import * from random import choice game = DoomGame() # Use CIG example config or Your own. game.load_config("../../examples/config/cig.cfg") # Select game and map You want to use. game.set_doom_game_path("../../scenarios/freedoom2.wad") #game.set_...
import os import pkg_resources from setuptools import setup, find_packages setup( name="clip", py_modules=["clip"], version="1.0", description="", author="OpenAI", packages=find_packages(exclude=["tests*"]), install_requires=[ str(r) for r in pkg_resources.parse_requirement...
from clip.clip import tokenize as _tokenize, load as _load, available_models as _available_models import re import string dependencies = ["torch", "torchvision", "ftfy", "regex", "tqdm"] # For compatibility (cannot include special characters in function name) model_functions = { model: re.sub(f'[{string.punctuation}]...
from .clip import *
from collections import OrderedDict from typing import Tuple, Union import numpy as np import torch import torch.nn.functional as F from torch import nn class Bottleneck(nn.Module): expansion = 4 def __init__(self, inplanes, planes, stride=1): super().__init__() # all conv layers have strid...
import hashlib import os import urllib import warnings from typing import Any, Union, List from pkg_resources import packaging import torch from PIL import Image from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize from tqdm import tqdm from .model import build_model from .simple_tokeni...
import gzip import html import os from functools import lru_cache import ftfy import regex as re @lru_cache() def default_bpe(): return os.path.join(os.path.dirname(os.path.abspath(__file__)), "bpe_simple_vocab_16e6.txt.gz") @lru_cache() def bytes_to_unicode(): """ Returns list of utf-8 byte and a corr...
import numpy as np import pytest import torch from PIL import Image import clip @pytest.mark.parametrize('model_name', clip.available_models()) def test_consistency(model_name): device = "cpu" jit_model, transform = clip.load(model_name, device=device, jit=True) py_model, _ = clip.load(model_name, device...
from setuptools import setup, find_packages setup( name="jcm", version="0.1", packages=find_packages(), package_dir={"jcm": "jcm"}, install_requires=[ "wandb", "clean-fid", "torchvision", "torch", "tensorflow", "tensorboard", "absl-py", ...
# Code modified from https://github.com/GaParmar/clean-fid/blob/main/cleanfid/fid.py # Original license below: # MIT License # # Copyright (c) 2021 Gaurav Parmar # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and as...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# Copyright 2021 The Flax Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wri...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# Copyright 2023 (c) OpenAI. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
# Code adapted from https://github.com/google-research/google-research/tree/master/flax_models/cifar # Original copyright statement: # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You ...
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
# Code from https://github.com/pcuenca/lpips-j/blob/main/src/lpips_j/lpips.py # # Original copyright statement: # Copyright 2021 The DALL·E mini Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the L...
from configs.default_cifar10_configs import get_default_configs from configs.cifar10_k_ve import get_config as get_ref_config import math def get_config(): config = get_default_configs() # training training = config.training training.sde = "kvesde" training.loss = "consistency_adaptive" train...
from configs.default_cifar10_configs import get_default_configs import math def get_config(): config = get_default_configs() # training training = config.training training.sde = "kvesde" training.loss = "dsm" training.batch_size = 512 training.n_iters = 400001 training.n_jitted_steps =...
from configs.default_cifar10_configs import get_default_configs from configs.cifar10_k_ve import get_config as get_ref_config import math def get_config(): config = get_default_configs() # training training = config.training training.sde = "kvesde" training.loss = "consistency_ema" training.r...
from configs.default_cifar10_configs import get_default_configs from configs.cifar10_k_ve import get_config as get_ref_config import math def get_config(): config = get_default_configs() # training training = config.training training.sde = "kvesde" training.loss = "continuous" training.ref_mo...
from configs.default_cifar10_configs import get_default_configs from configs.cifar10_k_ve import get_config as get_ref_config import math def get_config(): config = get_default_configs() # training training = config.training training.sde = "kvesde" training.loss = "progressive_distillation" t...
from configs.default_cifar10_configs import get_default_configs import math def get_config(): config = get_default_configs() # training training = config.training training.sde = "kvesde" training.loss = "dsm" training.batch_size = 512 training.n_iters = 400001 training.n_jitted_steps =...
from configs.default_cifar10_configs import get_default_configs from configs.cifar10_k_ve import get_config as get_ref_config import math def get_config(): config = get_default_configs() # training training = config.training training.sde = "kvesde" training.loss = "consistency" training.ref_m...
import ml_collections def get_default_configs(): config = ml_collections.ConfigDict() # training config.training = training = ml_collections.ConfigDict() training.batch_size = 128 training.n_iters = 1300001 training.snapshot_freq = 50000 training.log_freq = 50 training.eval_freq = 100 ...
from tqdm import tqdm from model import CLIPImage, CLIPText import tensorflow as tf import os import numpy as np from lucid.optvis import objectives, param import lucid.optvis.render as render from lucid.optvis.objectives import wrap_objective, diversity import lucid.optvis.transform as transform from lucid.misc.io im...
from tokenizer import SimpleTokenizer from model import CLIPImage, CLIPText import tensorflow as tf from lucid.misc.io import load import numpy as np def imresize(img, size, scale=255): from PIL import Image im = Image.fromarray((img*scale).astype(np.uint8) ) return np.array(im.resize(size, Image.BICUBIC))...
from lucid.modelzoo.vision_base import Model from lucid.optvis import render import tensorflow as tf from lucid.misc.io import load, save class CLIPImage(Model): image_value_range = (0, 255) input_name = 'input_image' def __init__(self): self.model_name = "RN50_4x" self.image_shape = [288,...
# By Alec Radford import html import ftfy import json import regex as re from functools import lru_cache import tensorflow as tf import blobfile def pad(x, pad_length = 76): z = np.zeros((pad_length)) z[0:len(x)] = x return z @lru_cache() def bytes_to_unicode(): """ Returns list of utf-8 byte and...