This project implements a style transfer application that allows users to upload an image and apply a specific artistic style to it (e.g., Van Gogh's Starry Night), using a pre-trained VGG19 model.
本项目实现了一个基于 VGG19 模型的风格迁移应用,用户可以上传图片并将其转换为特定艺术风格(如梵高星空)。
- Upload an image to the server.
- Apply a selected artistic style to the uploaded image.
- View the stylized image in the browser.
- Supports multiple styles through reference images.
style-transfer-project
├── backend
│ ├── app.py # Entry point for the backend application
│ ├── config.py # Configuration parameters for the application
│ ├── requirements.txt # Python dependencies
│ ├── core
│ │ ├── __init__.py
│ │ ├── style_transfer.py # Core logic for style transfer
│ │ ├── vgg19.py # VGG19 model definition and forward pass
│ │ └── layers.py # Custom layers for content and style loss
│ ├── utils
│ │ ├── __init__.py
│ │ └── image_processing.py # Image processing utility functions
│ ├── models
│ │ └── imagenet-vgg-verydeep-19.mat # Pre-trained VGG19 model weights
│ └── static
│ ├── input # Directory for uploaded images
│ └── output # Directory for generated images
├── frontend
│ ├── public
│ │ ├── index.html # Main HTML file for the frontend application
│ │ └── favicon.ico # Application icon
│ ├── src
│ │ ├── assets
│ │ │ └── style-reference.jpg # Reference style image
│ │ ├── components
│ │ │ ├── ImageUploader.vue # Component for image upload
│ │ │ └── ResultViewer.vue # Component for displaying results
│ │ ├── App.vue # Main component for the frontend application
│ │ ├── main.js # Entry point for the frontend application
│ │ └── api.js # API interaction methods
│ ├── package.json # Frontend project configuration
│ └── vite.config.js # Vite configuration for building the frontend
├── docker-compose.yml # Docker configuration for multi-container application
└── README.md # Project documentation
git clone https://github.com/woaiwang/style-transfer-project.git
cd style-transfer-project-
Clone the repository:
git clone <repository-url> cd style-transfer-project -
Set up the backend:
- Navigate to the
backenddirectory. - Install the required Python packages:
pip install -r requirements.txt
- Navigate to the
-
Set up the frontend:
- Navigate to the
frontenddirectory. - Install the required Node.js packages:
npm install
- Navigate to the
-
Start the backend server:
cd backend python app.py -
Start the frontend development server:
cd frontend npm run dev -
Open your browser and go to
http://localhost:3000to access the application.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.