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
from concurrent import futures | |
import logging | |
import os | |
import grpc | |
from protos import hello_pb2, hello_pb2_grpc | |
class Greeter(hello_pb2_grpc.GreeterServicer): | |
def SayHello(self, request, context): | |
return hello_pb2.StringResponse(message=f'Hello, {request.name}! Your age is {request.age}') |
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
from ldm.generate import Generate | |
# model configuration | |
gr = Generate( | |
'stable-diffusion-1.4', | |
embedding_path='./models/embeddings.pt' # modify the embedding path | |
) | |
# model loading | |
gr.load_model() |
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
python main.py --base ./configs/stable-diffusion/v1-finetune.yaml \ | |
-t \ | |
--actual_resume ./models/ldm/stable-diffusion-v1/model.ckpt \ | |
-n my_key \ | |
--gpus 0, \ | |
--data_root ./training_data/key/ |
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
from PIL import Image | |
import glob | |
size = (512, 512) | |
# get all the files in a folder, make sure all are image files | |
files = glob.glob('./training_data/raw/*') | |
for fil in files: | |
# implement file type checking here if required |
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
absl-py==1.2.0 | |
accelerate==0.12.0 | |
aiohttp==3.8.1 | |
aiosignal==1.2.0 | |
albumentations==0.4.3 | |
altair==4.2.0 | |
antlr4-python3-runtime==4.8 | |
async-timeout==4.0.2 | |
attrs==22.1.0 | |
backports.zoneinfo==0.2.1 |
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
from sentence_transformers import SentenceTransformer, util | |
import torch | |
model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2', device='cpu', cache_folder='/') | |
# Corpus with example sentences | |
corpus = [ | |
'I am a boy', | |
'What are you doing?', | |
'Can you help me?', |
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
from sentence_transformers import SentenceTransformer, util | |
import torch | |
# save model in current directory | |
model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2', device='cpu', cache_folder='./') | |
# save model in models folder (you need to create the folder on your own beforehand) | |
# model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2', device='cpu', cache_folder='./models/') | |
# Corpus with example sentences | |
corpus = [ |
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
version: 1 | |
disable_existing_loggers: False | |
formatters: | |
default: | |
"()": uvicorn._logging.DefaultFormatter | |
datefmt: "%Y-%m-%dT%H:%M:%S" | |
format: '[%(asctime)s.%(msecs)03dZ] %(name)s %(levelname)s %(message)s' | |
access: | |
"()": uvicorn._logging.AccessFormatter | |
datefmt: "%Y-%m-%dT%H:%M:%S" |
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
version: 1 | |
disable_existing_loggers: False | |
formatters: | |
default: | |
"()": uvicorn.logging.DefaultFormatter | |
datefmt: "%Y-%m-%dT%H:%M:%S" | |
format: '[%(asctime)s.%(msecs)03dZ] %(name)s %(levelname)s %(message)s' | |
access: | |
"()": uvicorn.logging.AccessFormatter | |
datefmt: "%Y-%m-%dT%H:%M:%S" |
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
from phonemizer.backend import EspeakBackend | |
backend = EspeakBackend('en-us', preserve_punctuation=True, with_stress=True) | |
text = ["Hello, world!", "Welcome to Medium!"] | |
phonemized = backend.phonemize(text, strip=True) | |
print(phonemized) |