Spaces:
Runtime error
Runtime error
1halfplusminus
commited on
Commit
β’
5569175
1
Parent(s):
91087cc
feat: first commit
Browse files- Dockerfile +26 -0
- README copy.md +13 -0
- export.pkl +3 -0
- main.py +26 -0
- requirements.txt +6 -0
Dockerfile
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
FROM python:3.9
|
5 |
+
|
6 |
+
WORKDIR /code
|
7 |
+
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
11 |
+
|
12 |
+
# Set up a new user named "user" with user ID 1000
|
13 |
+
RUN useradd -m -u 1000 user
|
14 |
+
# Switch to the "user" user
|
15 |
+
USER user
|
16 |
+
# Set home to the user's home directory
|
17 |
+
ENV HOME=/home/user \
|
18 |
+
PATH=/home/user/.local/bin:$PATH
|
19 |
+
|
20 |
+
# Set the working directory to the user's home directory
|
21 |
+
WORKDIR $HOME/app
|
22 |
+
COPY main.py main.py
|
23 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
24 |
+
COPY --chown=user . $HOME/app
|
25 |
+
|
26 |
+
CMD ["python", "main.py"]
|
README copy.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: LlamaAlpacaTron5000
|
3 |
+
emoji: π
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: pink
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.23.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ce5af6d51a72693a681f2fea5764adf7e2524a8843cd2e83d784b7eb33d2d487
|
3 |
+
size 46962511
|
main.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastcore.all import *
|
3 |
+
from fastai.vision.all import *
|
4 |
+
|
5 |
+
# Load the FastAI model
|
6 |
+
learn = load_learner('export.pkl')
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
# Define a function to classify an image
|
9 |
+
def classify_image(file):
|
10 |
+
|
11 |
+
# Run the model to get a prediction
|
12 |
+
pred_class, pred_idx, outputs = learn.predict(file)
|
13 |
+
# Return the predicted class
|
14 |
+
return {labels[i]: float(outputs[i]) for i in range(len(labels))}
|
15 |
+
|
16 |
+
# Create a Gradio interface
|
17 |
+
iface = gr.Interface(
|
18 |
+
fn=classify_image,
|
19 |
+
inputs=gr.components.Image(label="Image"),
|
20 |
+
outputs=gr.components.Label(num_top_classes=3),
|
21 |
+
title="Llamalpaca-tron 5000",
|
22 |
+
description="The llama-alpaca image classifier is a machine learning model designed to accurately identify whether an image contains a llama or an alpaca. Trained on a large dataset of llama and alpaca images, the model uses deep learning algorithms to analyze various features of the animals, such as their fur, body shape, and facial characteristics, and then makes a prediction based on those features. With high accuracy, this model can help identify llamas and alpacas in images, which can be useful for various applications, such as wildlife conservation, agriculture, and animal research.",
|
23 |
+
)
|
24 |
+
|
25 |
+
# Run the interface
|
26 |
+
iface.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
duckduckgo_search
|
3 |
+
gradio
|
4 |
+
torch
|
5 |
+
torchvision
|
6 |
+
requests
|