training fix. add global settings
This commit is contained in:
@@ -1,107 +1,107 @@
|
||||
# Python Backend for COCO Tool
|
||||
|
||||
This is the converted Python backend using Flask and SQLAlchemy.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Create a virtual environment (recommended):
|
||||
```bash
|
||||
python -m venv venv
|
||||
```
|
||||
|
||||
2. Activate the virtual environment:
|
||||
- Windows: `venv\Scripts\activate`
|
||||
- Linux/Mac: `source venv/bin/activate`
|
||||
|
||||
3. Install dependencies:
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Running the Server
|
||||
|
||||
### Option 1: Using start.py
|
||||
```bash
|
||||
python start.py
|
||||
```
|
||||
|
||||
### Option 2: Using Flask directly
|
||||
```bash
|
||||
python app.py
|
||||
```
|
||||
|
||||
### Option 3: Using Flask CLI
|
||||
```bash
|
||||
flask --app app run --host=0.0.0.0 --port=3000
|
||||
```
|
||||
|
||||
The server will start on `http://0.0.0.0:3000`
|
||||
|
||||
## Database Configuration
|
||||
|
||||
The database configuration is in `database/database.py`. Default settings:
|
||||
- Host: localhost
|
||||
- Database: myapp
|
||||
- User: root
|
||||
- Password: root
|
||||
|
||||
Modify `app.py` to change these settings.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
backend/
|
||||
├── app.py # Main Flask application
|
||||
├── start.py # Startup script
|
||||
├── requirements.txt # Python dependencies
|
||||
├── database/
|
||||
│ └── database.py # Database configuration
|
||||
├── models/ # SQLAlchemy models
|
||||
│ ├── __init__.py
|
||||
│ ├── Annotation.py
|
||||
│ ├── Images.py
|
||||
│ ├── LabelStudioProject.py
|
||||
│ ├── training.py
|
||||
│ ├── TrainingProject.py
|
||||
│ └── TrainingProjectDetails.py
|
||||
├── routes/
|
||||
│ └── api.py # API endpoints
|
||||
└── services/ # Business logic
|
||||
├── fetch_labelstudio.py
|
||||
├── generate_json_yolox.py
|
||||
├── generate_yolox_exp.py
|
||||
├── push_yolox_exp.py
|
||||
└── seed_label_studio.py
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
All endpoints are prefixed with `/api`:
|
||||
|
||||
- `GET /api/seed` - Seed database from Label Studio
|
||||
- `POST /api/generate-yolox-json` - Generate YOLOX training files
|
||||
- `POST /api/start-yolox-training` - Start YOLOX training
|
||||
- `GET /api/training-log` - Get training logs
|
||||
- `GET/POST /api/training-projects` - Manage training projects
|
||||
- `GET /api/label-studio-projects` - Get Label Studio projects
|
||||
- `GET/POST/PUT /api/training-project-details` - Manage project details
|
||||
- `POST /api/yolox-settings` - Save YOLOX settings
|
||||
- `GET/DELETE /api/trainings` - Manage trainings
|
||||
- `DELETE /api/training-projects/:id` - Delete training project
|
||||
|
||||
## Migration Notes
|
||||
|
||||
This is a direct conversion from Node.js/Express to Python/Flask:
|
||||
- Express → Flask
|
||||
- Sequelize ORM → SQLAlchemy ORM
|
||||
- node-fetch → requests library
|
||||
- Async routes maintained where needed
|
||||
- All file paths and logic preserved from original
|
||||
|
||||
## Differences from Node.js Version
|
||||
|
||||
1. Python uses async/await differently - some routes may need adjustments
|
||||
2. File handling uses Python's built-in open() instead of fs module
|
||||
3. Subprocess calls use Python's subprocess module
|
||||
4. JSON handling uses Python's json module
|
||||
5. Path operations use os.path instead of Node's path module
|
||||
# Python Backend for COCO Tool
|
||||
|
||||
This is the converted Python backend using Flask and SQLAlchemy.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Create a virtual environment (recommended):
|
||||
```bash
|
||||
python -m venv venv
|
||||
```
|
||||
|
||||
2. Activate the virtual environment:
|
||||
- Windows: `venv\Scripts\activate`
|
||||
- Linux/Mac: `source venv/bin/activate`
|
||||
|
||||
3. Install dependencies:
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Running the Server
|
||||
|
||||
### Option 1: Using start.py
|
||||
```bash
|
||||
python start.py
|
||||
```
|
||||
|
||||
### Option 2: Using Flask directly
|
||||
```bash
|
||||
python app.py
|
||||
```
|
||||
|
||||
### Option 3: Using Flask CLI
|
||||
```bash
|
||||
flask --app app run --host=0.0.0.0 --port=3000
|
||||
```
|
||||
|
||||
The server will start on `http://0.0.0.0:3000`
|
||||
|
||||
## Database Configuration
|
||||
|
||||
The database configuration is in `database/database.py`. Default settings:
|
||||
- Host: localhost
|
||||
- Database: myapp
|
||||
- User: root
|
||||
- Password: root
|
||||
|
||||
Modify `app.py` to change these settings.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
backend/
|
||||
├── app.py # Main Flask application
|
||||
├── start.py # Startup script
|
||||
├── requirements.txt # Python dependencies
|
||||
├── database/
|
||||
│ └── database.py # Database configuration
|
||||
├── models/ # SQLAlchemy models
|
||||
│ ├── __init__.py
|
||||
│ ├── Annotation.py
|
||||
│ ├── Images.py
|
||||
│ ├── LabelStudioProject.py
|
||||
│ ├── training.py
|
||||
│ ├── TrainingProject.py
|
||||
│ └── TrainingProjectDetails.py
|
||||
├── routes/
|
||||
│ └── api.py # API endpoints
|
||||
└── services/ # Business logic
|
||||
├── fetch_labelstudio.py
|
||||
├── generate_json_yolox.py
|
||||
├── generate_yolox_exp.py
|
||||
├── push_yolox_exp.py
|
||||
└── seed_label_studio.py
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
All endpoints are prefixed with `/api`:
|
||||
|
||||
- `GET /api/seed` - Seed database from Label Studio
|
||||
- `POST /api/generate-yolox-json` - Generate YOLOX training files
|
||||
- `POST /api/start-yolox-training` - Start YOLOX training
|
||||
- `GET /api/training-log` - Get training logs
|
||||
- `GET/POST /api/training-projects` - Manage training projects
|
||||
- `GET /api/label-studio-projects` - Get Label Studio projects
|
||||
- `GET/POST/PUT /api/training-project-details` - Manage project details
|
||||
- `POST /api/yolox-settings` - Save YOLOX settings
|
||||
- `GET/DELETE /api/trainings` - Manage trainings
|
||||
- `DELETE /api/training-projects/:id` - Delete training project
|
||||
|
||||
## Migration Notes
|
||||
|
||||
This is a direct conversion from Node.js/Express to Python/Flask:
|
||||
- Express → Flask
|
||||
- Sequelize ORM → SQLAlchemy ORM
|
||||
- node-fetch → requests library
|
||||
- Async routes maintained where needed
|
||||
- All file paths and logic preserved from original
|
||||
|
||||
## Differences from Node.js Version
|
||||
|
||||
1. Python uses async/await differently - some routes may need adjustments
|
||||
2. File handling uses Python's built-in open() instead of fs module
|
||||
3. Subprocess calls use Python's subprocess module
|
||||
4. JSON handling uses Python's json module
|
||||
5. Path operations use os.path instead of Node's path module
|
||||
|
||||
Reference in New Issue
Block a user