Skip to content

Instantly share code, notes, and snippets.

View MarcSkovMadsen's full-sized avatar

Marc Skov Madsen MarcSkovMadsen

View GitHub Profile
@MarcSkovMadsen
MarcSkovMadsen / gpt2_transformers.py
Last active October 30, 2021 07:46
Hugging Face GPT2 Transformer Example
import logging
import tensorflow as tf
from transformers import TFGPT2LMHeadModel, GPT2Tokenizer
from transformers import tf_top_k_top_p_filtering
import panel as pn
pn.extension()
@MarcSkovMadsen
MarcSkovMadsen / parent_child_parameters.py
Last active September 1, 2021 07:47
Examples of Parent-Child related selections using HoloViz Panel
import panel as pn
import pandas as pd
import param
pn.extension(sizing_mode="stretch_width")
LOGO = "https://holoviz.org/assets/panel.png"
ACCENT_BASE_COLOR = "#4099da"
SELECTED_COLOR = "#2c6b98"
@MarcSkovMadsen
MarcSkovMadsen / fastgridtemplate_walkthrough.py
Last active August 24, 2022 15:42
FastGridTemplate Walk Through
import holoviews as hv
import numpy as np
import panel as pn
pn.extension(sizing_mode="stretch_width")
ACCENT_COLOR = "#37718e" # "#DF3874"
XS = np.linspace(0, np.pi)
@MarcSkovMadsen
MarcSkovMadsen / panel_vs_code_interactive.py
Last active July 24, 2021 05:40
Code for showcasing the power of Panel in VS Code
# In order for Panel to work in VS Code you would need the jupyter_bokeh package
# In order for this example to work your would need `panel jupyter_bokeh altair vega_datasets ipykernel`
import panel as pn
import altair as alt
import vega_datasets
pn.extension("vega", sizing_mode="stretch_width")
# Lets show some interactivity
@MarcSkovMadsen
MarcSkovMadsen / matplotlib_interactive.py
Last active December 14, 2022 09:07
Matplotlib interactive extension
import panel as pn
from panel.pane.plot import Matplotlib as _MatplotlibPane
import param
import numpy as np
from matplotlib.figure import Figure
from matplotlib import cm
from matplotlib.backends.backend_agg import FigureCanvasAgg # not needed for mpl >= 3.1
pn.extension()
@MarcSkovMadsen
MarcSkovMadsen / holoviz_linked_brushing.py
Last active May 19, 2022 09:10
Linked brushing with HoloViz
# pip install panel==0.12.4 bokeh==2.4.0 holoviews==1.14.6 hvplot==0.7.3 shapely==1.7.1
# panel serve holoviz_linked_brushing.py --autoreload --show
import hvplot.pandas
import holoviews as hv
import panel as pn
from bokeh.sampledata.iris import flowers
pn.extension(sizing_mode="stretch_width")
hv.extension("bokeh")
"""This module contains functionality to run a command with autoreload.
The command will autoreload everytime a file in the folder or it's subfolders are updated
Use this as for example
```bash
python autoreload panel serve *.py
```