当前位置:网站首页>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)
边栏推荐
- Threadlocalutils (tool class IV)
- 将截断字符串或二进制数据
- 2022/0524/bookstrap
- JS Es5 can also create constants?
- 机器人队伍学习方法,实现8.8倍的人力回报
- The foreground downloads network pictures without background processing
- AcWing 904. Wormhole solution (SPFA for negative rings)
- Flir Blackfly S 工业相机 介绍
- Introduction to microservice architecture
- Get to know MySQL for the first time
猜你喜欢

处理streamlit库上传的图片文件

Scenario practice: quickly build wordpress blog system based on function calculation

How did partydao turn a tweet into a $200million product Dao in one year

UC伯克利助理教授Jacob Steinhardt预测AI基准性能:AI在数学等领域的进展比预想要快,但鲁棒性基准性能进展较慢

Recognition of C language array

Reptile practice (VI): novel of climbing pen interesting Pavilion

Flir Blackfly S 工业相机:通过外部触发实现多摄像头同步拍摄

Analyze "C language" [advanced] paid knowledge [II]

Vingt - trois mille feuilles? "Yang mou" derrière l'explosion de la consommation végétale

Shell script quickly counts the number of lines of project code
随机推荐
The use of video in the wiper component causes full screen dislocation
PartyDAO如何在1年内把一篇推文变成了2亿美金的产品DAO
centos8 用yum 安装MySQL 8.0.x
The GPG keys listed for the "MySQL 8.0 community server" repository are already ins
Zabbix 5.0:通过LLD方式自动化监控阿里云RDS
JS ES5也可以創建常量?
阿里云中间件开源往事
Web开发小妙招:巧用ThreadLocal规避层层传值
Modify the system time of Px4 flight control
大咖云集|NextArch基金会云开发Meetup来啦!
Time synchronization of livox lidar hardware -- PPS method
张平安:加快云上数字创新,共建产业智慧生态
Centos8 install MySQL 8.0 using yum x
MySQL最基本的SELECT(查询)语句
解密函数计算异步任务能力之「任务的状态及生命周期管理」
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
Ros Learning (23) Action Communication Mechanism
uva 1401 dp+Trie
LeetCode. Sword finger offer 62 The last remaining number in the circle
【LeetCode】Day97-移除链表元素