jessicaNono commited on
Commit
63231d8
·
2 Parent(s): c69e4df 843a55f

library to use the model

Browse files
Files changed (1) hide show
  1. README.md +81 -0
README.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ - fr
6
+ tags:
7
+ - computer vision
8
+ - deep learning
9
+ - pytorch
10
+ ---
11
+ # README for Image Colorization Model
12
+
13
+ Welcome to the GitHub repository for our Image Colorization model! This model uses deep learning to add vibrant colors to grayscale images, particularly focusing on historical photographs. Below you'll find instructions on how to set up and use this model.
14
+
15
+ ## Requirements
16
+ To use this model, you need the following:
17
+ - Python 3.8 or later
18
+ - PyTorch
19
+ - torchvision
20
+ - PIL (Pillow)
21
+ - scikit-image
22
+ - matplotlib
23
+ - numpy
24
+
25
+ You can install the necessary libraries using `pip`:
26
+ ```bash
27
+ pip install torch torchvision Pillow scikit-image matplotlib numpy
28
+ ```
29
+
30
+ ## Model Architecture
31
+ `ColorizationNet` is a neural network model built using PyTorch. It combines the power of ResNet and an upsampling network to colorize grayscale images.
32
+
33
+ ## Setup
34
+ First, clone this repository and navigate to the directory:
35
+ ```bash
36
+ git clone [repo-link]
37
+ cd [repo-directory]
38
+ ```
39
+
40
+ Download the trained model weights (`colorization_md1.pth`) and place them in the repository's root directory.
41
+
42
+ ## Usage
43
+
44
+ To colorize an image, follow these steps:
45
+
46
+ 1. **Prepare the Image**: Ensure your image is in grayscale format. You can use any standard image format like JPG or PNG.
47
+
48
+ 2. **Run the Model**: Use the following code to colorize your image.
49
+
50
+ ```python
51
+ from colorize import ColorizationNet, colorize_single_image
52
+ import torch
53
+ import torch.nn as nn
54
+
55
+ # Load the model
56
+ model = ColorizationNet()
57
+ model_path = 'colorization_md1.pth'
58
+ pretrained = torch.load(model_path, map_location=lambda storage, loc: storage)
59
+ model.load_state_dict(pretrained)
60
+ model.eval() # Set the model to evaluation mode
61
+
62
+ # Set the path to your image
63
+ image_path = 'path_to_your_image.jpg'
64
+ save_dir = 'dir_to_save_colorized_image'
65
+ criterion = nn.MSELoss()
66
+
67
+ # Colorize the image
68
+ use_gpu = torch.cuda.is_available()
69
+ colorize_single_image(image_path, model, criterion, save_dir, epoch=0, use_gpu=use_gpu)
70
+ ```
71
+
72
+ 3. **View the Results**: The colorized image will be saved in the specified `save_path`. You will find both the original grayscale and the colorized version there.
73
+
74
+ ## Contributions and Issues
75
+ Feel free to contribute to this project by submitting pull requests. If you encounter any issues or have questions, please submit them in the issues section of this repository.
76
+
77
+ ## License
78
+
79
+
80
+
81
+ Enjoy exploring the vibrant colors of history with our model! 🎨📸