Codelinhtinh commited on
Commit
abcf810
·
1 Parent(s): affa2df
Files changed (4) hide show
  1. Dockerfile +1 -1
  2. README.md +8 -80
  3. api.py +1 -1
  4. docker-compose.yml +2 -2
Dockerfile CHANGED
@@ -15,7 +15,7 @@ COPY . /app
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
  # Make port available to the world outside this container
18
- EXPOSE 8001
19
 
20
  # Run your FastAPI app
21
  CMD ["python", "api.py"]
 
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
  # Make port available to the world outside this container
18
+ EXPOSE 7860
19
 
20
  # Run your FastAPI app
21
  CMD ["python", "api.py"]
README.md CHANGED
@@ -1,80 +1,8 @@
1
- # Project Name
2
- 🌟Image Object Detection🌟
3
-
4
- ## Description
5
- This is a FastAPI-based web service that accepts an image upload and performs object detection on the image using a pre-trained model Yolov5m. It returns the annotated image with the detected objects.
6
-
7
- ## Table of Contents
8
- - [Installation](#installation)
9
- - [Features](#features)
10
- - [Usage](#usage)
11
- - [Configuration](#configuration)
12
- - [Contributing](#contributing)
13
- - [License](#license)
14
-
15
- ## Installation
16
- 1. Clone the repository:
17
- ```bash
18
- git clone https://github.com/Codelinhtinh/Exercises-AIO.git
19
- ```
20
- 2. Install project dependencies:
21
- ```bash
22
- pip install -r requirements.txt
23
- ```
24
- ## Features
25
- ✨This code is a FastAPI application that provides an API endpoint for performing predictions on uploaded images.
26
-
27
- ✨ It uses a pre-trained model to detect objects in images.
28
-
29
- ✨ Uploaded images are processed and resized to a specific image size defined in the CFG class.
30
-
31
- ✨ The final results are visualized on the original image using the visualize function.
32
-
33
- ✨The processed and visualized image is saved to a temporary file and returned as a response to the API request.
34
- ## Usage
35
- 1. Run the FastAPI server in makefile:
36
- ```bash
37
- uvicorn api:api --port 8000
38
- ```
39
-
40
- 2. Open your browser and navigate to `http://localhost:8000/docs` to check prediction.
41
- ![Alt Text](sample\api.gif)
42
-
43
- 3. Start the streamlit app in makefile:
44
- ```bash
45
- streamlit run app.py
46
- ```
47
- 4. Import image and wait:
48
- ![Alt Text](sample\Usage.gif)
49
-
50
- ## Configuration
51
- You can modify the configuration parameters of the model by updating the CFG class in the configs.py file. The available configuration options are:
52
-
53
- **image_size**: The size of the input image for prediction.
54
-
55
- **conf_thres**: The confidence threshold for object detection.
56
-
57
- **iou_thres**: The IoU (Intersection over Union) threshold for non-maximum suppression.
58
-
59
- Feel free to adjust these parameters according to your requirements.
60
-
61
-
62
- ## Contributing
63
- 🤝 Contributions are welcome! Please follow these guidelines when contributing to the project:
64
- 1. Fork the repository.
65
- 2. Create a new branch:
66
- ```bash
67
- git checkout -b feature/your-feature
68
- ```
69
- 3. Commit your changes:
70
- ```bash
71
- git commit -m 'Add your feature'
72
- ```
73
- 4. Push to the branch:
74
- ```bash
75
- git push origin feature/your-feature
76
- ```
77
- 5. Create a pull request.
78
-
79
- ## License
80
- 📝 This project is open source
 
1
+ ---
2
+ title: Basic Docker SDK Space
3
+ emoji: 🐳
4
+ colorFrom: purple
5
+ colorTo: gray
6
+ sdk: docker
7
+ app_port: 7860
8
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
api.py CHANGED
@@ -51,4 +51,4 @@ async def predict(file: UploadFile):
51
 
52
  if __name__ == "__main__":
53
  import uvicorn
54
- uvicorn.run(api, host="0.0.0.0", port=8001)
 
51
 
52
  if __name__ == "__main__":
53
  import uvicorn
54
+ uvicorn.run(api, host="0.0.0.0", port=7860)
docker-compose.yml CHANGED
@@ -5,12 +5,12 @@ services:
5
  context: .
6
  dockerfile: Dockerfile
7
  ports:
8
- - "8001:8001"
9
  command:
10
  - "uvicorn"
11
  - "api:api"
12
  - "--reload"
13
- - "--port=8001"
14
  - "--host=0.0.0.0"
15
  volumes:
16
  - .:/app # Replace with the path to your local code
 
5
  context: .
6
  dockerfile: Dockerfile
7
  ports:
8
+ - "7860:7860"
9
  command:
10
  - "uvicorn"
11
  - "api:api"
12
  - "--reload"
13
+ - "--port=7860"
14
  - "--host=0.0.0.0"
15
  volumes:
16
  - .:/app # Replace with the path to your local code