Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

streamlit uploaded image #2547

Closed
yupopa opened this issue Mar 21, 2021 · 3 comments
Closed

streamlit uploaded image #2547

yupopa opened this issue Mar 21, 2021 · 3 comments
Labels
question Further information is requested Stale

Comments

@yupopa
Copy link

yupopa commented Mar 21, 2021

❔Question

streamlit return BytesIO object when image uploaded how can ı pass through that type of object to my model. I use torch.hub.load to make an detection and ı used results function. How can ı pass through that type of image to results function? can you please help me

Additional context

ı am also getting this error
File "/home/appuser/.cache/torch/hub/ultralytics_yolov5_master/models/common.py", line 207, in forward
if im.shape[0] < 5: # image in CHW

@yupopa yupopa added the question Further information is requested label Mar 21, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2021

👋 Hello @yupopa, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

glenn-jocher commented Mar 23, 2021

@yupopa PyTorch Hub Tutorial contains example BytesIO usage:

Base64 Results

For use with API services. See #2291 for details.

results = model(imgs)  # inference

results.imgs # array of original images (as np array) passed to model for inference
results.render()  # updates results.imgs with boxes and labels
for img in results.imgs:
    buffered = BytesIO()
    img_base64 = Image.fromarray(img)
    img_base64.save(buffered, format="JPEG")
    print(base64.b64encode(buffered.getvalue()).decode('utf-8'))  # base64 encoded image with results

YOLOv5 Tutorials

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants