Skip to content

Conversation

@Zeyi-Lin
Copy link
Member

Description

Closes: #1367

@Zeyi-Lin Zeyi-Lin requested a review from SAKURA-CAT December 10, 2025 11:46
@Zeyi-Lin Zeyi-Lin self-assigned this Dec 10, 2025
@Zeyi-Lin Zeyi-Lin added the 💪 enhancement New feature or request label Dec 10, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Zeyi-Lin, 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 introduces a significant feature that enhances the flexibility of SwanLab's media logging capabilities by enabling 'nested media usage'. Users can now instantiate various media types (Audio, Image, Molecule, Text, Video) by providing an existing instance of the same media type. This allows for convenient manipulation, such as updating captions or resizing images, without needing to re-supply the raw data, thereby streamlining the logging workflow and improving API usability.

Highlights

  • Nested Media Type Support: The core functionality of this PR is to enable 'nested' usage for various media types (Audio, Image, Molecule, Text, Video). This means you can now pass an existing instance of a media object (e.g., swanlab.Audio) to the constructor of the same media type to create a new instance, potentially with updated parameters like a new caption.
  • Audio Module Enhancement: The Audio class now supports initializing a new Audio object from an existing Audio instance, allowing for easy duplication or modification of captions while preserving the original audio data and sample rate.
  • Image Module Enhancement: The Image class has been updated to accept existing Image instances as input, facilitating the creation of new images based on existing ones, with options to override format, size, and caption.
  • Molecule Module Enhancement: The Molecule class constructor now explicitly handles Molecule instances as input, enabling nested creation and allowing for caption updates without re-processing the PDB data.
  • Object3D Factory Update: The Object3D factory (__new__ method) has been extended to correctly process MediaType instances, specifically ensuring that Molecule objects can be passed and their captions updated when creating new Object3D instances.
  • Text Module Enhancement: The Text class now supports nested initialization, allowing a new Text object to be created from an existing Text instance, which is useful for updating captions or re-logging text data.
  • Video Module Enhancement: The Video class has been modified to accept existing Video instances, enabling nested usage and the ability to update captions for video logs.
  • Comprehensive Unit Testing: New unit tests have been added for Audio, Image, Molecule, Object3D, Text, and Video modules to thoroughly validate the new nested media usage functionality, ensuring correct data handling and caption overriding.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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
Contributor

@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 introduces support for nested media object creation, such as swanlab.Image(swanlab.Image(data)), across various media types including Audio, Image, Text, Video, Molecule, and Object3D. The changes are accompanied by new unit tests. While the overall implementation is good, I've identified a significant bug in Object3D's handling of nested types, some inconsistencies in the Audio class, and opportunities for code improvement in Molecule and Video classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

实现“套娃”上传媒体图像

2 participants