Skip to content

Added crop by class about ISD data type #146

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

HunJ93
Copy link

@HunJ93 HunJ93 commented Jun 24, 2025

목적

  • ELStateDetection 데이터 타입의 각 라벨 crop 기능 추가

내용

  • class.yaml 파일에서 ELStateDetection class를 받아와 각 class 디렉토리를 만듭니다.
  • 각 이미지의 json을 순회하며 label을 original 이미지에서 crop을 진행합니다.
  • original 이미지에서 crop된 이미지는 각 라벨 class 디렉토리로 들어갑니다.
  • 모든 작업이 끝나면 class 디렉토리가 비어져있으면 삭제합니다.

기능 동작 검증

  • 로컬 개발 환경에서 테스트 완료

각 class별 디렉토리
image

디렉토리 안 crop된 이미지
image

HunJ93 added 4 commits June 24, 2025 14:26
Signed-off-by: Hun Jung <[email protected]>
Signed-off-by: Hun Jung <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings June 24, 2025 05:45
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @HunJ93, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a significant new utility within the application, enabling the automated extraction and categorization of image regions based on their annotations. The primary goal is to streamline the process of creating class-specific image datasets from existing labeled data, which is crucial for machine learning workflows. This feature is integrated into the GUI for ease of use and includes robust handling for various scenarios, such as managing output directories and supporting only rectangular annotations.

Highlights

  • New Feature: Crop Labels by Class: I've introduced a new feature that allows users to crop labeled objects from images and organize them into class-specific directories. This is particularly designed for the ELStateDetection data type, enabling automated dataset preparation for specific object classes.
  • UI Integration: A new 'Crop Classes' action has been added to the application's user interface, accessible via the 'Administrator' menu and the main toolbar. This provides a convenient way to trigger the new cropping functionality directly from the GUI.
  • Dependency Update: The opencv-python library has been added as a new development dependency to support the image processing operations required for cropping.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a crop-by-class feature for ELStateDetection labels, organizing cropped images into class-specific folders.

  • Introduces OpenCV for image processing
  • Implements a new CLI tool to parse JSON annotations and crop images by class
  • Integrates a "Crop Classes" action with a keyboard shortcut into the GUI

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
requirements-dev.txt Added opencv-python for cropping functionality
labelme/config/default_config.yaml Added crop_classes keyboard shortcut
labelme/cli/crop_label_class.py New script to crop and organize images by class
labelme/app.py Integrated crop action into the GUI
Comments suppressed due to low confidence (2)

labelme/cli/crop_label_class.py:20

  • [nitpick] Consider renaming allow_class to allowed_classes to clearly indicate this holds multiple class names.
        self.allow_class = self.config['ELStateDetection']

labelme/cli/crop_label_class.py:50

  • [nitpick] The method name _created_class_dir is past tense; rename it to _create_class_dirs to reflect its action of creating directories.
    def _created_class_dir(self, input_dir):

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new feature to crop labeled objects from images based on their class. The implementation is a good start, but I've identified several critical and high-severity issues related to security, error handling, and application stability. My review includes suggestions to use yaml.safe_load for security, improve error handling to prevent crashes, and replace sys.exit() with proper exception handling to ensure a better user experience in the GUI application. Addressing these points will make the new feature much more robust and secure.

Copy link

@kjwoo31 kjwoo31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변경 내용 확인하였습니다! 고생하셨습니다

Copy link

@RobotisDongun RobotisDongun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다 고생하셨습니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants