当前位置:网站首页>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语言关于链表的代码看不懂?一篇文章让你拿捏二级指针并深入理解函数参数列表中传参的多种形式
- Treadpoolconfig thread pool configuration in real projects
- 454 Baidu Mianjing 1
- Cisp-pte practice explanation (II)
- Compile command line terminal swift
- The use of video in the wiper component causes full screen dislocation
- MySQL's most basic select statement
- HDU 4661 message passing (wood DP & amp; Combinatorics)
- ROS学习(十九)机器人SLAM功能包——cartographer
- Baidu flying general BMN timing action positioning framework | data preparation and training guide (Part 1)
猜你喜欢

Livox激光雷达硬件时间同步---PPS方法

FLIR blackfly s industrial camera: configure multiple cameras for synchronous shooting

Dall-E Mini的Mega版本模型发布,已开放下载

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

JVM 内存模型

STM32F4---PWM输出

@Before, @after, @around, @afterreturning execution sequence

大咖云集|NextArch基金会云开发Meetup来啦!

Modify the system time of Px4 flight control

ROS学习(十九)机器人SLAM功能包——cartographer
随机推荐
STM32F4---通用定时器更新中断
大咖云集|NextArch基金会云开发Meetup来啦!
JS es5 peut également créer des constantes?
Centos8 install MySQL 8.0 using yum x
Centros 8 installation MySQL Error: The gpg Keys listed for the "MySQL 8.0 Community Server" repository are already ins
场景实践:基于函数计算快速搭建Wordpress博客系统
微服务架构介绍
字符串转成日期对象
激光雷达:Ouster OS产品介绍及使用方法
Analyze "C language" [advanced] paid knowledge [II]
AcWing 1141. LAN problem solving (kruskalkruskal finding the minimum spanning tree)
处理streamlit库上传的图片文件
Ds-5/rvds4.0 variable initialization error
Baidu flying general BMN timing action positioning framework | data preparation and training guide (Part 2)
POJ 3177 redundant paths POJ 3352 road construction (dual connection)
JVM 内存模型
Mongodb checks whether the table is imported successfully
张平安:加快云上数字创新,共建产业智慧生态
XML to map tool class xmlmaputils (tool class V)
刨析《C语言》【进阶】付费知识【完结】