python - 将 ImageField 中的图像转换为 numpy 数组
问题描述
class Image(models.Model):
image = models.ImageField(upload_to="uploads/%Y/%m/%d", null=False, blank=True)
如何从 ImageField 转换为 numpy 数组?
解决方案
from PIL import Image
for image in unlabeled_images:
image.image.open()
img = np.array(Image.open(image.image).convert("RGB"))
我可以这样解决我自己的问题。如果有人有更好的解决方案告诉我
推荐阅读
- arrays - 如何在反应中将选择组件列表存储在数组中
- python - xPath 选择节点的 Svg 父节点
- javascript - Splitting a complicated (?) string in javascript
- reactjs - Styled Components - 通过 props 传递的内容(内容)
- vb.net - 将对象(ListView)放在前面不起作用
- c++ - hwnd 是 winuser.h 的 udefined c++ 导入
- reactjs - laravel reactjs pusher:存在通道响应为302
- sql - 我得到的错误是'Msg 8120,'Vendors.VendorName' 在选择列表中无效'
- python - Python使用瀑布逻辑在多列上加入两个熊猫数据框
- java - 在 Java 中类型转换回用户定义的对象