File size: 5,124 Bytes
fa7a439
 
c2ae33f
fa7a439
 
 
 
 
 
984f501
094d66d
 
 
 
fa7a439
 
39f56fe
eb6e853
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dc4e557
 
 
 
 
 
eb6e853
 
 
 
 
dc4e557
 
 
 
 
 
 
eb6e853
 
 
dc4e557
eb6e853
4edc9ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb6e853
 
 
 
 
 
 
 
 
 
 
 
dc4e557
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb6e853
 
 
dc4e557
eb6e853
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27b2150
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
---
title: Musheff Api
emoji: πŸ„
colorFrom: yellow
colorTo: green
sdk: docker
pinned: false
license: apache-2.0
short_description: Mushrooms Classification API
app-port: 7860
datasets:
  - SoFa325/12_popular_russia_mushrooms_edible_poisonous
models:
  - blasisd/musheff
---

# Musheff API - A Mushroom Classification REST API

**Identify edible and poisonous Russian mushrooms with AI-powered precision**

This project provides a production-ready REST API for classifying 12 common Russian mushroom species using computer vision. Built around the `musheff` fine-tuned EfficientNet-B3 model, it delivers vital safety insights by distinguishing between edible and poisonous varieties - potentially preventing dangerous misidentifications during foraging.

## Key Features

πŸ„ **Safety-first classification** - Critical edible/poisonous differentiation  
🧠 **State-of-the-art model** - Fine-tuned `EfficientNet-B3` architecture  
🌲 **Regional specialization** - Optimized for 12 common Russian species  
⚑️ **Production-ready** - Scalable REST API implementation  
πŸ” **Transparent foundations** - Built on openly available datasets

## Technical Foundation

Powered by:

- Model: **[musheff](https://huggingface.co/blasisd/musheff)** (Custom fine-tuned EfficientNet-B3)
- Dataset: **[12_popular_russia_mushrooms_edible_poisonous](https://huggingface.co/datasets/SoFa325/12_popular_russia_mushrooms_edible_poisonous)**

## Getting Started

This guide provides step-by-step instructions to set up and run the project on your local machine for development and testing purposes. For details on deploying the project to a production environment, refer to the Deployment section.

### Prerequisites

To set up and run this project, ensure the following software and tools are installed on your system:

- **Python**: Version `3.10.12` or higher is required. Verify your Python version by running:

  ```bash
  python3 --version
  ```

- **Dependencies**: Install the required Python packages listed in requirements.txt using pip. Run the following command in your terminal:

  ```bash
  pip install -r requirements.txt
  ```

- **Docker (Optional)**: For containerized deployment. Install from [Docker's official site](https://docs.docker.com/get-docker/) and verify with:

  ```bash
  docker --version
  ```

### Local Development and Testing

To run the application locally for development and testing purposes, execute the following command in your terminal:

```bash
uvicorn main:app --host 0.0.0.0 --port 7860 --reload
```

If it does not work, just try:

```bash
python -m uvicorn main:app --host 0.0.0.0 --port 7860 --reload
```

> [!WARNING]
> Ensure you are in the project's **src** directory before running the script or adapt running path (i.e. `python -m uvicorn src.main:app --host 0.0.0.0 --port 7860 --reload`).

## How to Use

The API exposes a classification endpoint at `/classify` that accepts mushroom images and returns:

- Predicted mushroom species
- Edibility status (edible/poisonous)
- Confidence score

### API Endpoint

`POST /classify`

### Request Format

```bash
curl -X POST "http://<your-api-url>/classify" \
  -H "Content-Type: multipart/form-data" \
  -F "image_file=@path/to/mushroom.jpg"
```

### Example Response

```bash
{
    "mushroom_type": "Pleurotus_ostreatus",
    "toxicity_profile": "edible",
    "confidence": 0.5491
}
```

## Deployment

### Deployment on Hugging Face Spaces

To deploy the project on Hugging Face Spaces, follow these steps:

1. Create an account on [Hugging Face](https://huggingface.co) if you don’t already have one.

2. Refer to the official [Spaces Overview](https://huggingface.co/docs/hub/en/spaces-overview) documentation for detailed instructions on setting up and deploying your project.

### Docker-based Deployment

#### Locally

- Build your docker image:

  ```bash
  docker build -t musheff-api .
  ```

- Run a container based on the image:

  ```bash
  docker run -it -p 7860:7860 musheff-api
  ```

#### On Hugging Face

1. Follow the official [Docker Spaces Guide](https://huggingface.co/docs/hub/en/spaces-sdks-docker-first-demo) for container setup.
2. Copy the available `Dockerfile` to your repository root or create your own.
3. Configure settings requirements in `README.md` metadata (especially app_port if you need a different port to use):

```yaml
---
title: Musheff Api
emoji: πŸ„
colorFrom: yellow
colorTo: green
sdk: docker
pinned: false
license: apache-2.0
short_description: Mushrooms Classification API
app-port: 7860
datasets:
  - SoFa325/12_popular_russia_mushrooms_edible_poisonous
models:
  - blasisd/musheff
---
```

### Deployment on Other Cloud Platforms

For deployment on other cloud or live systems, consult the documentation provided by your chosen service provider. Each platform may have specific requirements and steps for deploying Python-based applications.

## Built With

- [Python 3.10.12](http://www.python.org/) - Developing with the best programming language

## Authors

**Vlasios Dimitriadis** - _Initial work:_ [Musheff API](https://huggingface.co/spaces/blasisd/musheff-api)

```

```