Spaces:
Runtime error
Runtime error
Karan Goel
commited on
Commit
ยท
2a5a2cc
1
Parent(s):
5321014
update
Browse files- Dockerfile +5 -4
- tutorial-1.py +0 -71
Dockerfile
CHANGED
@@ -43,10 +43,11 @@ ENV MEERKAT_LOG_DIR=$HOME/logs
|
|
43 |
RUN chmod 777 $HOME/
|
44 |
ENV MEERKAT_CONFIG=$HOME/config.yaml
|
45 |
|
46 |
-
COPY --chown=user ./tutorial
|
47 |
|
48 |
-
RUN mk run $HOME/tutorial-1.py --host 0.0.0.0 --api-port 7860
|
49 |
|
50 |
-
|
|
|
51 |
|
52 |
-
# CMD ["mk", "run", "$HOME/tutorial
|
|
|
43 |
RUN chmod 777 $HOME/
|
44 |
ENV MEERKAT_CONFIG=$HOME/config.yaml
|
45 |
|
46 |
+
COPY --chown=user ./tutorial.py $HOME/tutorial.py
|
47 |
|
48 |
+
# RUN mk run $HOME/tutorial-1.py --host 0.0.0.0 --api-port 7860
|
49 |
|
50 |
+
WORKDIR $HOME
|
51 |
+
CMD ["uvicorn", "tutorial:page", "--host", "0.0.0.0", "--port", "7860"]
|
52 |
|
53 |
+
# CMD ["mk", "run", "$HOME/tutorial.py", "--host", "0.0.0.0", "--api-port", "7860"]
|
tutorial-1.py
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
import meerkat as mk
|
2 |
-
|
3 |
-
print("Starting Meerkat...")
|
4 |
-
|
5 |
-
df = mk.get("imagenette", version="160px")
|
6 |
-
IMAGE_COL = "img"
|
7 |
-
LABEL_COL = "label"
|
8 |
-
|
9 |
-
|
10 |
-
@mk.reactive()
|
11 |
-
def random_images(df: mk.DataFrame):
|
12 |
-
images = df.sample(16)[IMAGE_COL]
|
13 |
-
formatter = images.formatters["base"]
|
14 |
-
return [formatter.encode(img) for img in images]
|
15 |
-
|
16 |
-
labels = list(df[LABEL_COL].unique())
|
17 |
-
class_selector = mk.gui.Select(
|
18 |
-
values=list(labels),
|
19 |
-
value=labels[0],
|
20 |
-
)
|
21 |
-
|
22 |
-
filtered_df = mk.reactive(lambda df, label: df[df[LABEL_COL] == label])(
|
23 |
-
df, class_selector.value
|
24 |
-
)
|
25 |
-
|
26 |
-
images = random_images(filtered_df)
|
27 |
-
|
28 |
-
grid = mk.gui.html.gridcols4(
|
29 |
-
[
|
30 |
-
mk.gui.html.div(mk.gui.Image(data=img), style="aspect-ratio: 1 / 1")
|
31 |
-
for img in images
|
32 |
-
],
|
33 |
-
classes="gap-2",
|
34 |
-
)
|
35 |
-
|
36 |
-
|
37 |
-
layout = mk.gui.html.flexcol(
|
38 |
-
[
|
39 |
-
mk.gui.html.div(
|
40 |
-
[mk.gui.Caption("Choose a class:"), class_selector],
|
41 |
-
classes="flex justify-center items-center mb-2 gap-4",
|
42 |
-
),
|
43 |
-
grid,
|
44 |
-
]
|
45 |
-
)
|
46 |
-
page = mk.gui.Page(component=layout, id="tutorial-1")
|
47 |
-
import os
|
48 |
-
from fastapi.staticfiles import StaticFiles
|
49 |
-
# from meerkat.interactive.startup import file_find_replace
|
50 |
-
# print(os.getcwd())
|
51 |
-
# print(os.path.abspath("./meerkat/interactive/app/build/"))
|
52 |
-
# libpath = os.path.abspath("./meerkat/interactive/app/")
|
53 |
-
# api_url = "http://localhost:5000"
|
54 |
-
# file_find_replace(
|
55 |
-
# libpath + "build",
|
56 |
-
# r"(VITE_API_URL\|\|\".*?\")",
|
57 |
-
# f'VITE_API_URL||"{api_url}"',
|
58 |
-
# "*.js",
|
59 |
-
# )
|
60 |
-
# file_find_replace(
|
61 |
-
# libpath + ".svelte-kit/output/client/_app/",
|
62 |
-
# r"(VITE_API_URL\|\|\".*?\")",
|
63 |
-
# f'VITE_API_URL||"{api_url}"',
|
64 |
-
# "*.js",
|
65 |
-
# )
|
66 |
-
from meerkat.constants import PathHelper
|
67 |
-
print(PathHelper().appdir)
|
68 |
-
print("Mounting static files...")
|
69 |
-
page().mount("/", StaticFiles(directory=os.path.abspath(PathHelper().appdir + "/build/"), html=True), "test")
|
70 |
-
# page().mount("/static", StaticFiles(directory=os.path.abspath("./temp/"),html = True), "test")
|
71 |
-
page.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|