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 fastapi import FastAPI, WebSocket, WebSocketDisconnect | |
app = FastAPI() | |
@app.websocket("/ws") | |
async def websocket_endpoint(websocket: WebSocket): | |
await websocket.accept() | |
try: | |
while True: |
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
#1 import | |
try: | |
import configparser | |
except: | |
from six.moves import configparser | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
import requests |
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
import android.content.Context; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import androidx.room.Database; | |
import androidx.room.Room; | |
import androidx.room.RoomDatabase; | |
@Database(entities = {User.class}, version = 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
import asyncio | |
import aiohttp | |
import time | |
async def gather_with_concurrency(n, *tasks): | |
semaphore = asyncio.Semaphore(n) | |
async def sem_task(task): | |
async with semaphore: |
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
import cv2 as cv | |
frame_width = 680 | |
frame_height = 480 | |
fps = 30.0 | |
video_capture = cv.VideoCapture(0) | |
video_capture.set(cv.CAP_PROP_FRAME_WIDTH, frame_width) | |
video_capture.set(cv.CAP_PROP_FRAME_HEIGHT, frame_height) |
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
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) |
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
from fastapi import FastAPI, Body | |
from pydantic import BaseModel | |
app = FastAPI() | |
class Number(BaseModel): | |
value: int | |
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
import ws from 'k6/ws'; | |
import { check } from 'k6'; | |
export let options = { | |
stages: [ | |
{ duration: '10s', target: 30 }, | |
{ duration: '30s', target: 30 }, | |
{ duration: '20s', target: 60 }, | |
{ duration: '30s', target: 60 }, | |
{ duration: '20s', target: 30 }, |