-
Notifications
You must be signed in to change notification settings - Fork 447
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
vision模型图片上传没压缩? #539
Comments
chagpt 自己会压缩分辨率的啊。 |
我也不知道为啥,实测nextweb是没问题的,小文件也没问题,4MB左右的都不行,下次我再排查一下试试吧,我用的oneapi转换的 |
前面加nginx了嘛? 如果有加的话需要调一下 nginx的 |
加过了,不知道报错在什么地方,等我有空再次复现仔细查看一下日志再向您反馈,感谢 |
确定了一下,就是我的api不兼容大文件,确实是需要压缩一下才能用🙃 |
为了解决这个问题我用python弄了个图片压缩服务器,在请求api的时候多一次图片压缩的请求体转发 from flask import Flask, request, jsonify
import base64
import io
from PIL import Image
app = Flask(__name__)
@app.route('/', defaults={'path': ''}, methods=['POST'])
@app.route('/<path:path>', methods=['POST'])
def compress_image(path):
data = request.get_json()
image_data = data.get('image')
image_bytes = base64.b64decode(image_data)
image = Image.open(io.BytesIO(image_bytes))
image = image.convert('RGB')
quality = 80
compressed_image_buffer = io.BytesIO()
image.save(compressed_image_buffer, format='JPEG', optimize=True, quality=quality)
compressed_image_buffer.seek(0)
compressed_image_base64 = base64.b64encode(compressed_image_buffer.getvalue()).decode('utf-8')
return jsonify({'image': compressed_image_base64})
if __name__ == '__main__':
app.run() |
nodejs有合适的库能干这个么。有的话可以考虑把这个功能集成到项目里面来。 |
前端的压缩方法挺多的,我只是不会js😵 |
上传大文件模型就报错,小的就正常
The text was updated successfully, but these errors were encountered: