当前位置:网站首页>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)
边栏推荐
- 【唯一】的“万字配图“ | 讲透【链式存储结构】是什么?
- C language [23] classic interview questions [Part 2]
- Golang foundation - data type
- Time synchronization of livox lidar hardware -- PPS method
- Redis configuration class redisconfig
- STM32F4---PWM输出
- The use of video in the wiper component causes full screen dislocation
- How can I code for 8 hours without getting tired.
- Recognition of C language array
- Analyze "C language" [advanced] paid knowledge [i]
猜你喜欢
ROS learning (26) dynamic parameter configuration
Blackfly s usb3 industrial camera: buffer processing
New job insights ~ leave the old and welcome the new~
Analyze "C language" [advanced] paid knowledge [i]
C语言关于链表的代码看不懂?一篇文章让你拿捏二级指针并深入理解函数参数列表中传参的多种形式
阿里云中间件开源往事
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
AcWing 361. Sightseeing cow problem solution (SPFA seeking positive ring)
将截断字符串或二进制数据
Big guys gather | nextarch foundation cloud development meetup is coming!
随机推荐
ROS learning (24) plugin
JS es5 peut également créer des constantes?
红外相机:巨哥红外MAG32产品介绍
Modify the system time of Px4 flight control
Public key \ private SSH avoid password login
Curl command
将截断字符串或二进制数据
ROS学习(十九)机器人SLAM功能包——cartographer
centos8安裝mysql報錯:The GPG keys listed for the “MySQL 8.0 Community Server“ repository are already ins
CISP-PTE实操练习讲解(二)
Input and output of C language pointer to two-dimensional array
Get to know MySQL for the first time
POJ 3177 redundant paths POJ 3352 road construction (dual connection)
刨析《C语言》【进阶】付费知识【完结】
C language [23] classic interview questions [Part 2]
MySQL's most basic select statement
Integrated navigation: product description and interface description of zhonghaida inav2
Blackfly S USB3工业相机:缓冲区处理
一片葉子兩三萬?植物消費爆火背後的“陽謀”
Word wrap when flex exceeds width