A19grey's picture
Updating to new 3D visualizer molgallery3D and need to restart space to install
0f5f6d3

A newer version of the Gradio SDK is available: 5.27.0

Upgrade

The gradio_molgallery3d package is a custom component for Gradio, designed specifically for displaying an interactive gallery of 3D molecular structures. Here are some key features and details: Installation: You can install this component using pip install gradio_molgallery3d. Input: It accepts inputs in the form of RDKit objects, which are commonly used for cheminformatics and molecular modeling. Features: Automatic Rotation: When the automatic_rotation parameter is set to True, the molecular structures rotate automatically, providing a dynamic view of the molecule. Download Capability: Users can download the 3D structure as a .png file by clicking the right mouse button on the structure. Known Issues: Web browsers have limitations on the number of canvas objects that can be displayed on a single page, which might result in some structures not being drawn. This limitation varies by browser. Example Usage for Visualizing H2O: Here's a code snippet to show how you can use gradio_molgallery3d to visualize the H2O molecule:

import gradio as gr from rdkit import Chem from gradio_molgallery import MolGallery3D

Create an RDKit molecule object for H2O

h2o_mol = Chem.MolFromSmiles('O')

Set up the gallery

gallery3d = MolGallery3D( columns=1, # Since we're showing only one molecule height=400, # Adjust the height as needed label="3D Structure of H2O", automatic_rotation=True )

Define a function to return the molecule

def show_h2o(): return [h2o_mol]

Create the Gradio interface

with gr.Blocks() as demo: gr.Markdown("# 3D Visualization of H2O") gallery = gallery3d btn = gr.Button("Show H2O") btn.click(fn=show_h2o, outputs=gallery)

Launch the demo

demo.launch()