Add application file
Browse files
app.py
CHANGED
|
@@ -25,6 +25,13 @@ def perform_inference(model, processor, image, prompt):
|
|
| 25 |
"""
|
| 26 |
推論の実行
|
| 27 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
messages = [
|
| 29 |
{
|
| 30 |
"role": "user",
|
|
|
|
| 25 |
"""
|
| 26 |
推論の実行
|
| 27 |
"""
|
| 28 |
+
# 画像の幅を512pxにリサイズし、縮尺を保つ
|
| 29 |
+
target_width = 512
|
| 30 |
+
width_percent = (target_width / float(image.size[0]))
|
| 31 |
+
target_height = int((float(image.size[1]) * float(width_percent)))
|
| 32 |
+
image = image.resize((target_width, target_height), Image.Resampling.LANCZOS)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
messages = [
|
| 36 |
{
|
| 37 |
"role": "user",
|