当前位置:网站首页>A few lines of code, let black and white old photos regain their vitality!
A few lines of code, let black and white old photos regain their vitality!
2022-07-19 15:56:00 【Python Technology】
writing | Leisure and joy
source :Python technology 「ID: pythonall」
Hello everyone , I am carefree , Today we continue to liver !
In recent years, Tiktok has really gone deep into the streets , It has brought considerable income to countless people .
One of the sub categories is repairing old photos , The content is to release an old photo to show the effect after restoration , Traffic is pretty good .
Old photos are easy to resonate , Many people will associate some scenes of themselves when they see old photos, especially characters 、 Some relatives , Remembrance and remembrance , Is of great significance , Some people even repair old photos , Find relatives who have been separated for many years ...
It is said that it was drained to Taobao stores , The annual revenue is ten million , It makes my mouth water , I want to master this technology , Can you make a lot of money , No more volume programs , Be a walrus lying flat !
I came across an open source Git project , The theme is to repair old photos , Color old photos , The effect is really good .
This project is DeOldify , stay GitHub Got it. 15.2k My little star , It is very popular . I'm even thinking , Are those Taobao shop owners using this project to make money ( Puzzled face )?
Quick experience
The author provides us with a multilingual interface , By calling this interface, we can quickly use the capabilities of the project , To color old photos .
Let's first experience the power of the project through this simple interface .
import requests
r = requests.post(
"https://api.deepai.org/api/colorizer",
files={
'image': open('/path/to/your/file.jpg', 'rb'),
},
headers={'api-key': 'quickstart-QUdJIGlzIGNvbWluZy4uLi4K'}
)
print(r.json())
Before running this code , Please change the image path to your local old photo path .
I casually used an old photo here , The original photo is like this :
Run the program , A shaded photo path will be printed on the console , Copy path to browser , We can see the colored photos :
Stunned, you mu you , This effect is powerful !
In addition to getting local photos , Coloring , You can also get photos on the Internet . I casually found a black-and-white photo on the Internet :

Then use the interface program :
import requests
r = requests.post(
"https://api.deepai.org/api/colorizer",
data={
'image': 'https://pics0.baidu.com/feed/43a7d933c895d143712f08474bd47c0b5aaf0723.jpeg',
},
headers={'api-key': 'quickstart-QUdJIGlzIGNvbWluZy4uLi4K'}
)
print(r.json())
Run the program , Wait for a few seconds , The console will print out the results :
This face immediately ruddy ! But some details are still not handled well .
summary
It's just about DeOldify The easiest way to use it , Just a few lines of code , however DeOldify So popular , It's definitely not that simple , The principle behind it is very professional , Very complicated , If you are interested, you can go to its homepage to study , It also provides three different training libraries for advanced people , You can download them , Combined with the source code, set parameters for debugging .
Today's article is here , King of the Qin Dynasty ...
PS: Reply within company number 「Python」 You can enter Python Novice learning communication group , Together 100 Day plan !
Old rules , Brothers, remember , Right lower corner “ Looking at ” click , If you think the content of the article is good , Remember to share the circle of friends and let more people know !
【 Mystery gift bag Access method 】
Identify the QR code at the end of the text , reply :1024
边栏推荐
- Learning notes of JUC source code 2 - AQS sharing and semaphore, countdownlatch
- Identity Server 4使用OpenID Connect添加用户身份验证(三)
- Detailed explanation of the life cycle of arkui development framework components
- QT | qcombobox of control
- 阿叶的新发型
- Advanced C language - struct implementation bit segment
- 开源WPF控件库-AdonisUI
- wpa_ supplicant @authenticate
- ADN公益加速 —— Jsdelivr npm(国内),ElmCDN的优质替代方案
- 努力锻炼游泳技能
猜你喜欢
[FPGA]: IP core ----- CIC filter
我应该怎么设计我的博客?如何搭建一个体验好的博客?
【干货】MySQL底层架构设计,你了解多少?
Excel cell settings drop-down options
232. Implement queue with stack
如何正确重写hashCode方法?
Next stop, embossed AI
Open3d library installation, CONDA common instructions, importing open3d times this error solving environment: failed with initial frozen solve Retrying w
群里的初级工程师求助说,要采集采招数据,必须给他安排上
Woman Yelling At a Cat
随机推荐
遥远的距离
Windows install MySQL
Caddy's introduction
安静的等待
PAT乙级-B1005 继续(3n+1)猜想分数(25)【map解决】
通过群晖虚拟机搭建内网邮件服务器「ExtMail 免费版」
BFD of HCNP Routing & Switching
A thorough understanding of bio, NiO, AIO
投资和生活分开
LVS负载均衡群集
鲲鹏代码迁移工具基础知识
The junior engineer in the group asked for help and said that if he wanted to collect the recruitment data, he must be arranged
biji
Adn public welfare acceleration - jsdelivr NPM (domestic), a high-quality alternative to elmcdn
Pat grade b-b1005 continue (3n+1) guess score (25) [map solve]
阿叶的新发型
Force plan - how can I participate in the force plan
王者荣耀商城异地多活架构设计
【历史上的今天】7 月 17 日:软银收购 ARM;第一次电子邮件中断;维基媒体国际会议
Series operations of stack and queue containers (detailed explanation)