taesiri commited on
Commit
b6e6733
β€’
1 Parent(s): 3c53027

initial commit

Browse files
Files changed (4) hide show
  1. Dockerfile +24 -0
  2. README.md +1 -1
  3. app.py +26 -0
  4. requirements.txt +5 -0
Dockerfile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN apt-get update && apt-get upgrade -y && apt-get install -y libgl1-mesa-dev
8
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
9
+
10
+ # Set up a new user named "user" with user ID 1000
11
+ RUN useradd -m -u 1000 user
12
+ # Switch to the "user" user
13
+ USER user
14
+ # Set home to the user's home directory
15
+ ENV HOME=/home/user \
16
+ PATH=/home/user/.local/bin:$PATH
17
+
18
+ # Set the working directory to the user's home directory
19
+ WORKDIR $HOME/app
20
+
21
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
22
+ COPY --chown=user . $HOME/app
23
+
24
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -3,7 +3,7 @@ title: ImageNet Hard Browser
3
  emoji: 🐨
4
  colorFrom: red
5
  colorTo: gray
6
- sdk: gradio
7
  sdk_version: 3.24.1
8
  app_file: app.py
9
  pinned: false
 
3
  emoji: 🐨
4
  colorFrom: red
5
  colorTo: gray
6
+ sdk: docker
7
  sdk_version: 3.24.1
8
  app_file: app.py
9
  pinned: false
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import fiftyone as fo
2
+ from io import BytesIO
3
+ from PIL import Image
4
+ from datasets import load_dataset
5
+ import os
6
+
7
+ # Load the dataset
8
+ imagenet_hard_dataset = load_dataset("taesiri/imagenet-hard", split="validation")
9
+
10
+ # same every image on disk and save path in a list
11
+
12
+ os.makedirs("dataset", exist_ok=True)
13
+
14
+ list_of_images = []
15
+
16
+ for i in range(len(imagenet_hard_dataset)):
17
+ image = imagenet_hard_dataset[i]["image"].convert("RGB")
18
+ image.save(f"dataset/{i}.JPEG", "JPEG", quality=100)
19
+ list_of_images.append(f"imagenet_hard_images/{i}.jpg")
20
+
21
+
22
+ if __name__ == "__main__":
23
+ # Ensures that the App processes are safely launched on Windows
24
+ dataset = fo.Dataset.from_images_dir("./dataset/")
25
+ session = fo.launch_app(dataset, port=7860)
26
+ session.wait()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fiftyone
2
+ transformers
3
+ datasets
4
+ tqdm
5
+ numpy