当前位置:网站首页>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)
边栏推荐
- Vingt - trois mille feuilles? "Yang mou" derrière l'explosion de la consommation végétale
- Make DIY welding smoke extractor with lighting
- ROS learning (26) dynamic parameter configuration
- 张平安:加快云上数字创新,共建产业智慧生态
- Can't you understand the code of linked list in C language? An article allows you to grasp the secondary pointer and deeply understand the various forms of parameter passing in the function parameter
- Modify the system time of Px4 flight control
- 我如何编码8个小时而不会感到疲倦。
- AcWing 1148. Secret milk transportation problem solution (minimum spanning tree)
- Input and output of C language pointer to two-dimensional array
- First experience of JSON learning - the third-party jar package realizes bean, list and map to create JSON format
猜你喜欢
Word wrap when flex exceeds width
Analyze "C language" [advanced] paid knowledge [End]
FLIR blackfly s industrial camera: explanation and configuration of color correction and code setting method
Shell script quickly counts the number of lines of project code
Time synchronization of livox lidar hardware -- PPS method
Flir Blackfly S工业相机:颜色校正讲解及配置与代码设置方法
centos8 用yum 安装MySQL 8.0.x
AcWing 345. Cattle station solution (nature and multiplication of Floyd)
Introduction to microservice architecture
Cisp-pte practice explanation (II)
随机推荐
6 seconds to understand the book to the Kindle
Get to know MySQL for the first time
Analyze "C language" [advanced] paid knowledge [i]
WCF Foundation
ROS学习(22)TF变换
JVM memory model
ROS learning (21) robot slam function package -- installation and testing of orbslam
Integrated navigation: product description and interface description of zhonghaida inav2
初识MySQL
【LeetCode】Day97-移除链表元素
The use of video in the wiper component causes full screen dislocation
ROS learning (22) TF transformation
Treadpoolconfig thread pool configuration in real projects
SchedulX V1.4.0及SaaS版发布,免费体验降本增效高级功能!
Related programming problems of string
When grep looks for a process, it ignores the grep process itself
Seconds understand the delay and timing function of wechat applet
AcWing 1148. Secret milk transportation problem solution (minimum spanning tree)
一片叶子两三万?植物消费爆火背后的“阳谋”
Hutool post requests to set the body parameter to JSON data