-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This wiki is about using repo. If you want to know about the overall project, please refer to this link.
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
This is an example of how to list things you need to use the software and how to install them.
- OpenCV with contrib modules
pip install opencv-contrib-python
- Scipy 1.2.0(Important)
pip install scipy==1.2.0
- Pillow
pip install pillow
- Tensorflow
pip install tensorflow==2.2.0
- Keras
pip install Keras==2.2.0
- Numpy
pip install numpy
Or you can install the libraries you need to use at once. It is suitable when using a new virtual environment (interpreter).
pip install -r requirements.txt
-
Complete the prerequisite settings
-
Clone the repo
git clone https://github.com/doljae/convert_image_maker.git
-
Unzip the repo and put the folder in the path to use the library.
-
Please refer to the manual to
import
and use the library. -
For detailed usage instructions, see
user_guide.pdf
This section describes the overall structure of the project and how to use it.
./
| README.md
| requirements.txt
| test.py --> Usage example
|
+---image
| | image_handle.py --> Image handler class(include extraction, conversion fucntion)
| | readme.txt
| |
| +---clean_back
| | apple.png --> sample image for conversion using specific object
| |
| +---crop_images
| | crop_0.jpg --> results of object extraction in input image
| | crop_1.jpg
| | crop_2.jpg
| | crop_X.jpg
| | crop_location.txt --> location of cropped images
| | cut_image1.jpg --> The image from which the detected internal objects are extracted.
| | cut_image2.jpg
| |
| +---result_images
| | converted_image.jpg --> The final converted result
| | original_image.jpg --> input image
| | readme.txt
| |
+---pix2pix
| | data_loader.py
| | pix2pix.py --> conversion using GAN
| |
| +---datasets
| | \---tmp
| | +---saved
| | | crop_0.jpg --> Internal object already converted due to GAN model
| | | crop_1.jpg
| | | crop_2.jpg
| | | crop_X.jpg
| | |
| | \---test
| +---keras_contrib
| |
\---socket
| | receive_convert_send.py --> Server, Receive an image to an external device and send the converted image
Please refer to test.py
for specific usage.
from image.image_handle import convertImageMaker
import os
import glob
import random
files = glob.glob('./image/crop_images/*')
for f in files:
os.remove(f)
convertTest=convertImageMaker()
convertTest.image_extract()
convertTest.image_save_crop_location()
convertTest.image_convert(convert_type=2)
# convertTest.image_convert(convert_type=random.randint(1,4))
- Import libraries
from image.image_handle import convertImageMaker
import os
import glob
import random
The python module is sensitive to path setting. Please import the module with the correct path through the functions of the IDE.
os
, glob
, and random
are not essential import modules.
- Initialize
convertImageMaker
class
convertTest=convertImageMaker()
This class has 3 functions(image_extract()
, image_save_crop_location()
, image_convert(convert_type=X)
)
- Object detection & extraction
convertTest.image_extract()
This function searches for the object inside the input image, extracts it and saves it.
The extracted results are saved in ./image/crop_images/crop_X.jpg
. (See Structure)
- Save the location of extracted object in input image
convertTest.image_save_crop_location()
This function stores the location of the extracted object.
This value is relative to the original image and is represented by four integer values of (x_po, y_po, width, height).
The results are saved in ./image/crop_images/crop_location.txt
. (See Structure)
- Transforms the extracted object and combines it with the original image to return the result.
convertTest.image_convert(convert_type=2)
The conversion method is determined by the convert_type parameter.
The conversion method according to the parameter value is as follows.
convert_type=1 --> Rotation
convert_type=2 --> Color inversion
convert_type=3 --> Substitution
convert_type=4 --> GAN conversion
The target of all conversion methods is the object image extracted from the original image.
- Result
The converted image is saved in
./image/result_images/converted_image.jpg
. (See Structure)
-
Module version dependency
This project is module version sensitive. We are currently updating the stable release version, including the latest version of TensorFlow.
Especially, in case of conversion using GAN model, please check the wiki and error log if it does not work properly. -
Conversion according to GAN model
The GAN model converts objects to other similar objects. And, like an AI model, there is a possibility that a similar transformation may be made by learning data, or vice versa.
Of course, the conversion itself is fine, so there is no problem when using only the converted internal object image.
If other problems occur, please register as an open issues.