Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

ObjectDetectionData.from_images raise an error #1530

Closed
serabiasin opened this issue Mar 9, 2023 · 0 comments · Fixed by #1667
Closed

ObjectDetectionData.from_images raise an error #1530

serabiasin opened this issue Mar 9, 2023 · 0 comments · Fixed by #1667
Labels
bug / fix Something isn't working help wanted Extra attention is needed

Comments

@serabiasin
Copy link

serabiasin commented Mar 9, 2023

🐛 Bug

after pass the datamodule into finetune, at the end of the epoch it throws an error message:

/opt/conda/lib/python3.7/site-packages/flash/core/data/utilities/classification.py in _strip(x)
     44 
     45 def _strip(x: str) -> str:
---> 46     return x.strip(", ")
     47 
     48 

AttributeError: 'int' object has no attribute 'strip'

To Reproduce

Code sample

datamodule snipset code was from documentation

from flash.image import ObjectDetectionData, ObjectDetector
from PIL import Image
import numpy as np
from flash import Trainer

datamodule = ObjectDetectionData.from_images(
    train_images=[
        Image.fromarray(np.random.randint(0, 255, (512, 512, 3), dtype="uint8")),
         Image.fromarray(np.random.randint(0, 255,(512, 512, 3), dtype="uint8")),
         Image.fromarray(np.random.randint(0, 255, (512, 512, 3), dtype="uint8")),
    ],
         train_targets=[["cat"], ["cat"], ["cat"]],
     train_bboxes=[
         [{"xmin": 10, "ymin": 20, "width": 5, "height": 10}],
         [{"xmin": 20, "ymin": 30, "width": 10, "height": 10}],
         [{"xmin": 10, "ymin": 20, "width": 5, "height": 25}],
     ],
     predict_images=[Image.fromarray(np.random.randint(0, 255, (512, 512, 3), dtype="uint8"))],
     transform_kwargs=dict(image_size=(512, 512)),
     batch_size=2,
 )

model=ObjectDetector(
                        head="efficientdet", 
                        backbone="d0",
                        image_size=512,
                        labels=datamodule.labels,

                    )

trainer = Trainer(max_epochs=20,accelerator="gpu")
trainer.finetune(model, datamodule=datamodule, strategy="freeze")

Expected behavior

It should not throw an error after the end of an epoch

Environment

  • OS (e.g., Linux): Ubuntu
  • Python version: 3.7.111
  • PyTorch/Lightning/Flash Version : pytorch-lightning==1.7.0, lightning-flash==0.8.0
  • GPU models and configuration: Quadro T2000, Cuda Version 11.4
@serabiasin serabiasin added bug / fix Something isn't working help wanted Extra attention is needed labels Mar 9, 2023
@Borda Borda changed the title ObjectDetectionData from_images raise an error ObjectDetectionData.from_images raise an error May 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant