当前位置:网站首页>Processing image files uploaded by streamlit Library
Processing image files uploaded by streamlit Library
2022-07-07 02:07:00 【huijigo】
steamlit It is an interface that can quickly build a website . In the training program arranged by the school , We want to realize the design and implementation of content-based image retrieval system . The branch task is to retrieve the uploaded image .
We used steamlit Of uploadfile Components , This component can upload the pictures we need to the back-end program in bytes . Now the problem is how to analyze this 16 Base file .
The solution is PIL Library Image.open(); He can not only directly read the files under the file path , You can also read files through byte streams .
from io import BytesIO
import numpy as np
from PIL import Image
import streamlit as st
import cv2
# establish file_uploader Components
uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:
# To read file as bytes:
bytes_data = uploaded_file.getvalue()
# Convert byte data into byte stream
bytes_data = BytesIO(bytes_data)
#Image.open() Byte stream can be read
capture_img = Image.open(bytes_data)
capture_img = cv2.cvtColor(np.asarray(capture_img), cv2.COLOR_RGB2BGR)
边栏推荐
- Batch delete data in SQL - set in entity
- NPM install compilation times "cannot read properties of null (reading 'pickalgorithm')“
- Add PDF Title floating window
- Make DIY welding smoke extractor with lighting
- ROS学习(25)rviz plugin插件
- AcWing 904. Wormhole solution (SPFA for negative rings)
- AcWing 1141. LAN problem solving (kruskalkruskal finding the minimum spanning tree)
- Reptile practice (VI): novel of climbing pen interesting Pavilion
- 阿里云中间件开源往事
- sql中批量删除数据---实体中的集合
猜你喜欢

【唯一】的“万字配图“ | 讲透【链式存储结构】是什么?

3D激光SLAM:Livox激光雷达硬件时间同步

Modify the system time of Px4 flight control

PartyDAO如何在1年内把一篇推文变成了2亿美金的产品DAO

BigDecimal 的正确使用方式

454 Baidu Mianjing 1

Flir Blackfly S工业相机:颜色校正讲解及配置与代码设置方法

Make DIY welding smoke extractor with lighting

ROS学习(十九)机器人SLAM功能包——cartographer

Scenario practice: quickly build wordpress blog system based on function calculation
随机推荐
WCF Foundation
将截断字符串或二进制数据
Cat recycling bin
STM32F4---PWM输出
Treadpoolconfig thread pool configuration in real projects
AcWing 1140. Shortest network (minimum spanning tree)
ROS学习(十九)机器人SLAM功能包——cartographer
@Before, @after, @around, @afterreturning execution sequence
Telnet,SSH1,SSH2,Telnet/SSL,Rlogin,Serial,TAPI,RAW
ROS学习(23)action通信机制
Image watermarking, scaling and conversion of an input stream
HDU 4661 message passing (wood DP & amp; Combinatorics)
Web开发小妙招:巧用ThreadLocal规避层层传值
强化学习如何用于医学影像?埃默里大学最新《强化学习医学影像分析》综述,阐述最新RL医学影像分析概念、应用、挑战与未来方向
Blue Bridge Cup 2022 13th provincial competition real topic - block painting
Reptile practice (VI): novel of climbing pen interesting Pavilion
uva 1401 dp+Trie
Analyze "C language" [advanced] paid knowledge [i]
使用Ceres进行slam必须要弄清楚的几个类和函数
The GPG keys listed for the "MySQL 8.0 community server" repository are already ins