Spaces:
Running
Running
trevorpfiz
commited on
Commit
·
b42e995
1
Parent(s):
45ee60e
first commit
Browse files- .dockerignore +2 -0
- .gitignore +16 -0
- .python-version +1 -0
- Dockerfile +24 -13
- pyproject.toml +13 -0
- requirements.txt +0 -3
- run.sh +29 -0
- src/streamlit_app.py +0 -40
- src/vlm_playground/__init__.py +8 -0
- src/vlm_playground/app.py +18 -0
- uv.lock +0 -0
.dockerignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
# Exclude the project virtual environment from image builds
|
2 |
+
.venv
|
.gitignore
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Python-generated files
|
2 |
+
__pycache__/
|
3 |
+
*.py[oc]
|
4 |
+
build/
|
5 |
+
dist/
|
6 |
+
wheels/
|
7 |
+
*.egg-info
|
8 |
+
|
9 |
+
# Virtual environments
|
10 |
+
.venv
|
11 |
+
|
12 |
+
# env
|
13 |
+
.env
|
14 |
+
|
15 |
+
# AACT
|
16 |
+
.aact/
|
.python-version
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
3.12
|
Dockerfile
CHANGED
@@ -1,21 +1,32 @@
|
|
1 |
-
FROM
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
software-properties-common \
|
9 |
-
git \
|
10 |
-
&& rm -rf /var/lib/apt/lists/*
|
11 |
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
|
|
18 |
|
19 |
-
|
|
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
+
# Enable bytecode compilation and copy mode for mounted volumes
|
6 |
+
ENV UV_COMPILE_BYTECODE=1
|
7 |
+
ENV UV_LINK_MODE=copy
|
|
|
|
|
|
|
8 |
|
9 |
+
# Install dependencies from lockfile using cache/bind mounts
|
10 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
11 |
+
--mount=type=bind,source=uv.lock,target=uv.lock \
|
12 |
+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
13 |
+
uv sync --locked --no-install-project --no-dev
|
14 |
|
15 |
+
# Then, add the rest of the project source code and install it
|
16 |
+
# Installing separately from its dependencies allows optimal layer caching
|
17 |
+
COPY . /app
|
18 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
19 |
+
uv sync --locked --no-dev
|
20 |
|
21 |
+
# Place executables in the environment at the front of the path
|
22 |
+
ENV PATH="/app/.venv/bin:$PATH"
|
23 |
|
24 |
+
# Reset entrypoint; don't invoke uv directly
|
25 |
+
ENTRYPOINT []
|
26 |
|
27 |
+
EXPOSE 7860
|
28 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
29 |
+
ENV GRADIO_SERVER_PORT="7860"
|
30 |
+
|
31 |
+
# Default command
|
32 |
+
CMD ["uv", "run", "python", "-m", "vlm_playground.app"]
|
pyproject.toml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[project]
|
2 |
+
name = "vlm-playground"
|
3 |
+
version = "0.1.0"
|
4 |
+
description = "Minimal Gradio demo containerized with uv"
|
5 |
+
readme = "README.md"
|
6 |
+
requires-python = ">=3.12"
|
7 |
+
dependencies = [
|
8 |
+
"gradio>=5.41.1",
|
9 |
+
]
|
10 |
+
|
11 |
+
[build-system]
|
12 |
+
requires = ["uv_build>=0.8.6,<0.9.0"]
|
13 |
+
build-backend = "uv_build"
|
requirements.txt
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
altair
|
2 |
-
pandas
|
3 |
-
streamlit
|
|
|
|
|
|
|
|
run.sh
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env sh
|
2 |
+
#
|
3 |
+
# Build and run the example Docker image.
|
4 |
+
#
|
5 |
+
# Mounts the local project directory to reflect a common development workflow.
|
6 |
+
#
|
7 |
+
# The `docker run` command uses the following options:
|
8 |
+
#
|
9 |
+
# --rm Remove the container after exiting
|
10 |
+
# --volume .:/app Mount the current directory to `/app` so code changes don't require an image rebuild
|
11 |
+
# --volume /app/.venv Mount the virtual environment separately, so the developer's environment doesn't end up in the container
|
12 |
+
# --publish 7860:7860 Expose the Gradio server port 7860 to the host
|
13 |
+
# -it $(docker build -q .) Build the image, then use it as a run target
|
14 |
+
# $@ Pass any arguments to the container
|
15 |
+
|
16 |
+
if [ -t 1 ]; then
|
17 |
+
INTERACTIVE="-it"
|
18 |
+
else
|
19 |
+
INTERACTIVE=""
|
20 |
+
fi
|
21 |
+
|
22 |
+
docker run \
|
23 |
+
--rm \
|
24 |
+
--volume .:/app \
|
25 |
+
--volume /app/.venv \
|
26 |
+
--publish 7860:7860 \
|
27 |
+
$INTERACTIVE \
|
28 |
+
$(docker build -q .) \
|
29 |
+
"$@"
|
src/streamlit_app.py
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
import altair as alt
|
2 |
-
import numpy as np
|
3 |
-
import pandas as pd
|
4 |
-
import streamlit as st
|
5 |
-
|
6 |
-
"""
|
7 |
-
# Welcome to Streamlit!
|
8 |
-
|
9 |
-
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
|
10 |
-
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
|
11 |
-
forums](https://discuss.streamlit.io).
|
12 |
-
|
13 |
-
In the meantime, below is an example of what you can do with just a few lines of code:
|
14 |
-
"""
|
15 |
-
|
16 |
-
num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
|
17 |
-
num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
|
18 |
-
|
19 |
-
indices = np.linspace(0, 1, num_points)
|
20 |
-
theta = 2 * np.pi * num_turns * indices
|
21 |
-
radius = indices
|
22 |
-
|
23 |
-
x = radius * np.cos(theta)
|
24 |
-
y = radius * np.sin(theta)
|
25 |
-
|
26 |
-
df = pd.DataFrame({
|
27 |
-
"x": x,
|
28 |
-
"y": y,
|
29 |
-
"idx": indices,
|
30 |
-
"rand": np.random.randn(num_points),
|
31 |
-
})
|
32 |
-
|
33 |
-
st.altair_chart(alt.Chart(df, height=700, width=700)
|
34 |
-
.mark_point(filled=True)
|
35 |
-
.encode(
|
36 |
-
x=alt.X("x", axis=None),
|
37 |
-
y=alt.Y("y", axis=None),
|
38 |
-
color=alt.Color("idx", legend=None, scale=alt.Scale()),
|
39 |
-
size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
|
40 |
-
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/vlm_playground/__init__.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Top-level package for vlm_playground.
|
2 |
+
|
3 |
+
This file exists to satisfy build backends that expect a concrete Python
|
4 |
+
module at `src/vlm_playground/__init__.py` derived from the distribution
|
5 |
+
name `vlm-playground` (hyphens become underscores).
|
6 |
+
"""
|
7 |
+
|
8 |
+
__all__: list[str] = []
|
src/vlm_playground/app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
def greet(name: str) -> str:
|
5 |
+
return f"Hello {name}!!"
|
6 |
+
|
7 |
+
|
8 |
+
demo = gr.Interface(
|
9 |
+
fn=greet,
|
10 |
+
inputs="text",
|
11 |
+
outputs="text",
|
12 |
+
title="VLM Playground Gradio Demo",
|
13 |
+
description="Simple demo app to verify Gradio + uv Docker setup.",
|
14 |
+
)
|
15 |
+
|
16 |
+
|
17 |
+
if __name__ == "__main__":
|
18 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
uv.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|