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 | |
from fastapi.responses import HTMLResponse | |
import gradio as gr | |
app = FastAPI() | |
HELLO_ROUTE = "/hello" | |
GOODBYE_ROUTE = "/goodbye" | |
index_html = ''' |
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 io | |
from typing import Any, Callable, Iterator, Tuple, Union | |
import cv2 | |
from google.cloud import storage | |
import numpy as np | |
from PIL import Image | |
import tarfile | |
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 logging | |
from typing import Any, Dict, Type | |
class Registry: | |
""" | |
A factory register pattern | |
How to Use this Pattern |
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
#!/bin/bash | |
# Add a timestamp to the python's output. | |
# Example: | |
# dpython -c "[print(i) for i in range(5)]" | |
# [2019-01-20 14:19:39] 0 | |
# [2019-01-20 14:19:39] 1 | |
# [2019-01-20 14:19:39] 2 | |
# [2019-01-20 14:19:39] 3 | |
# [2019-01-20 14:19:39] 4 | |
# Setup: |
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 multiprocessing import Process, Manager, Pool | |
from multiprocessing.managers import AutoProxy | |
from typing import Any, List, Optional, Tuple | |
END_OF_QUEUE = None | |
class WorkersPool: | |
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
# FizzBuzz | |
print(*[(('','Fizz')[i%3==0] + ('','Buzz')[i%5==0]) if (i%3==0 or i%5==0) else i for i in range(1, 101)], sep="\n") |
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 tensorflow.keras.models import Model | |
from tensorflow.keras.layers import Input | |
def split_model(model, split_layer_name=None, split_layer_index=None): | |
""" | |
Split a trained model for predictions. | |
If `split_layer_name` and `split_layer_index` are both provided, `split_layer_index` will take precedence. | |
Indices are based on order of horizontal graph traversal (bottom-up). |
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
name: graph | |
source code: |- | |
#input: '111#1#11#11#11#1#111#111#11' | |
#input: '1#11' | |
input: '11#11#1' | |
#input: '11###1' | |
#input: '111' | |
blank: ' ' | |
start state: check_zero_nodes | |
table: |
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
name: binary palindrome enumerator | |
source code: | | |
# Adds 1 to a binary number. | |
input: '' | |
blank: ' ' | |
start state: setup_a | |
table: | |
# binary generator | |
setup_a: | |
' ' : {write: '#', L: setup_b} |
NewerOlder