DL-Playground is an interactive, web-based visual editor for designing, prototyping, and understanding PyTorch neural network architectures.
This tool provides an intuitive drag-and-drop interface that empowers developers and learners to build complex deep learning models without writing code from scratch. See your architecture come to life, from individual layers to complete computational graphs, and instantly generate the corresponding Python code.
- Visual Graph Editor: Built with React Flow, allowing for intuitive drag-and-drop construction of models. Connect, arrange, and configure layers with ease.
- Extensive Node Library: A rich collection of PyTorch layers and operations, including:
- Core Layers: Linear, Activations (ReLU, Sigmoid, etc.), Softmax, Flatten, Reshape.
- Convolutional/Vision: Conv2d, MaxPool2d, AvgPool2d, Upsample, Residual Blocks.
- Recurrent/Sequence: LSTM, GRU, RNN, Multi-head Attention, Embeddings.
- Losses & Metrics: MSELoss, CrossEntropyLoss, BCELoss, Accuracy.
- Real-time Code Generation: Instantly compiles the visual graph into a clean, readable, and copy-pasteable PyTorch
nn.Moduleclass, complete with__init__andforwardmethods. - Modular & Reusable Components: Encapsulate parts of your graph into custom modules and reuse them throughout your architecture, promoting a clean and organized workflow.
- Live Shape Inference: Calculates and displays tensor shapes as you build, helping to debug shape-related errors before they happen.
- Model Inspection: Leverage the integrated
torchlensbackend to analyze and visualize model summaries and internal states. - Built-in Code Editor: A Monaco-powered editor to view and refine the generated Python code directly in the application.
- Export to Image: Export your final graph visualization as a PNG image for documentation or presentations.
- Frontend:
- Framework: React
- Language: TypeScript
- Graph Visualization: React Flow
- Backend:
- Framework: FastAPI
- Language: Python
- Deep Learning: PyTorch
- Model Analysis: TorchLens
To get the application running locally, follow these steps.
git clone https://github.com/your-username/DL-Playground.git
cd DL-Playgrounddocker build -t torchlens-worker:latest ./backend/docker compose up -d --buildThe frontend will be available at http://localhost:7000. Open this URL in your browser to start using the playground!
- Open the Application: Navigate to the frontend URL in your browser.
- Add Nodes: Drag layers and operations from the sidebar onto the canvas.
- Configure Nodes: Click on a node to adjust parameters like kernel size, output features, etc.
- Connect Nodes: Drag from the output handle of one node to the input handle of another to create a connection.
- View Generated Code: As you build the graph, the corresponding PyTorch code will automatically update in the "Code" panel.
- Create Modules: Select a group of nodes using Shift + L-Click and save a module to create your own building block.
- Export: Use the export buttons to save a SVG image of your graph or copy the generated Python code.
This project is a combined effort from the DSG Club and SDSLabs at IIT Roorkee.
Contributions are welcome! If you have ideas for new features, bug fixes, or improvements, please feel free to open an issue or submit a pull request. See CONTRIBUTING.md for more details.