Skip to content

Commit e406bd8

Browse files
authored
Add files via upload
1 parent 5c6a328 commit e406bd8

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

Python/ToonifyImage/Readme.MD

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Toonify a Given Image
2+
3+
## Introduction
4+
```
5+
This is a python application which takes a image as input and toonify it (make a cartoonist image of it) using https://deepai.org/machine-learning-model/toonify api.
6+
You can read more about the Api here : https://deepai.org/machine-learning-model/toonify
7+
```
8+
## Third Party Libraries Required :
9+
1. Request Module # to fetch given image
10+
2. shutil Module # to save image locally
11+
12+
## How to install above Library
13+
```
14+
pip install requests
15+
pip install shutil
16+
```
17+
## How to use it :
18+
1. Download or clone the repository
19+
2. Install Required Libraries
20+
4. Run toonify.py
21+
3. In command line add you api key which you will get by signing up on https://deepai.org/machine-learning-model/toonify
22+
5. you will be asked to give the path of image you want to toonify
23+
6. you will get the toonified image in the same directory
24+
25+
## Output
26+
27+
### Original image
28+
29+
![endpoint](https://github.com/Tejas1510/hacking-tools-scripts/blob/toonify/Python/ToonifyImage/images/rohit.png)
30+
31+
### Toonified image
32+
33+
![endpoint](https://github.com/Tejas1510/hacking-tools-scripts/blob/toonify/Python/ToonifyImage/images/output.jpg)
34+
35+
![built with love](https://forthebadge.com/images/badges/built-with-love.svg)
36+
37+
Check out my Github profile [Tejas1510!](https://github.com/Tejas1510)

Python/ToonifyImage/images/output.jpg

120 KB
Loading

Python/ToonifyImage/images/rohit.png

12.1 KB
Loading

Python/ToonifyImage/output.jpg

120 KB
Loading

Python/ToonifyImage/toonify.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import requests
2+
import shutil # to save image locally
3+
imagePath=input("Please enter the path of image to toonify : ")
4+
api_key=input("Please enter your api key")
5+
r = requests.post(
6+
"https://api.deepai.org/api/toonify",
7+
files={
8+
'image': open(imagePath, 'rb'),
9+
},
10+
headers={'api-key': api_key}
11+
)
12+
y=r.json()
13+
image_url=y['output_url']
14+
filename = image_url.split("/")[-1]
15+
# Open the url image
16+
r1 = requests.get(image_url, stream = True)
17+
# Check if the image was retrieved successfully
18+
if r1.status_code == 200:
19+
# Set decode_content value to True, otherwise the downloaded image file's size will be zero.
20+
r1.raw.decode_content = True
21+
# Open a local file with wb ( write binary ) permission.
22+
with open(filename,'wb') as f:
23+
shutil.copyfileobj(r1.raw, f)
24+
print('Image sucessfully Downloaded: ',filename)
25+
else:
26+
print('Image Couldn\'t be retreived')

0 commit comments

Comments
 (0)