Example for discussion: https://discuss.streamlit.io/t/how-to-evolve-complex-state-e-g-annotate-data/
Install the requirements.
fastapi==0.42.0
streamlit==0.49.0
uvicorn==0.9.1
Run the server.
# Create a directory with images named 1.jpg, 2.jpg, 3.jpg, etc. | |
# Generate a custom color palette | |
ffmpeg -framerate 0.5 -i %d.jpg \ | |
-vf "format=rgba,fps=0.5,palettegen=stats_mode=diff" \ | |
-y palette.png | |
# Create the gif | |
ffmpeg -framerate 0.5 -i %d.jpg -i palette.png \ | |
-lavfi "format=rgba,fps=0.5,paletteuse=dither=none" \ |
import numpy as np | |
import streamlit as st | |
from .streamlit_utils import SessionState | |
session_state = SessionState.get(page=1) | |
def main(): | |
# Render the readme as markdown using st.markdown. |
def soft_dice_loss(y_true, y_pred, epsilon=1e-6): | |
''' | |
Soft dice loss calculation for arbitrary batch size, number of classes, and number of spatial dimensions. | |
Assumes the `channels_last` format. | |
# Arguments | |
y_true: b x X x Y( x Z...) x c One hot encoding of ground truth | |
y_pred: b x X x Y( x Z...) x c Network output, must sum to 1 over c channel (such as after softmax) | |
epsilon: Used for numerical stability to avoid divide by zero errors | |
from keras.callbacks import Callback | |
import keras.backend as K | |
import numpy as np | |
class SGDRScheduler(Callback): | |
'''Cosine annealing learning rate scheduler with periodic restarts. | |
# Usage | |
```python | |
schedule = SGDRScheduler(min_lr=1e-5, |
import numpy as np | |
from keras.callbacks import LearningRateScheduler | |
def step_decay_schedule(initial_lr=1e-3, decay_factor=0.75, step_size=10): | |
''' | |
Wrapper function to create a LearningRateScheduler with step decay schedule. | |
''' | |
def schedule(epoch): | |
return initial_lr * (decay_factor ** np.floor(epoch/step_size)) | |
import matplotlib.pyplot as plt | |
import keras.backend as K | |
from keras.callbacks import Callback | |
class LRFinder(Callback): | |
''' | |
A simple callback for finding the optimal learning rate range for your model + dataset. | |