Skip to content

Latest commit

ย 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GUI Simulator - Drawing with LLMs

Python License GUI LLM

Interactive graphical simulator for the "Drawing with LLMs" Kaggle competition project

A complete tool for generating SVG graphics from textual descriptions using language models


๐ŸŽฏ Project Description

GUI Simulator is a standalone application with graphical interface developed as part of the "Drawing with LLMs" project for the Kaggle competition. This simulator allows experimenting with automatic SVG code generation from textual descriptions in natural language, using both traditional processing techniques and advanced language models (LLMs).

๐Ÿ† Competition Context

This project is part of the "Drawing with LLMs" Kaggle competition, where the goal is to develop systems capable of generating accurate and creative SVG graphical representations from textual descriptions. The GUI simulator provides an interactive platform to experiment with different approaches and evaluate model performance.

โœจ Main Features

๐Ÿ–ฅ๏ธ Advanced Graphical Interface

  • Intuitive design: Developed with tkinter for maximum compatibility
  • Organized panels: Clear separation between input, results and metrics
  • Real-time: Dynamic updates during processing
  • Responsive: Interface adaptable to different resolutions

๐Ÿค– Multi-platform LLM Integration

  • OpenAI GPT: Support for GPT-3.5 and GPT-4
  • HuggingFace: Open source local models
  • Ollama: Integration with optimized local models
  • Traditional fallback: Rule-based SVG generator

๐Ÿ“Š Complete Performance Analysis

  • GPU metrics: Usage and memory monitoring of multiple GPUs
  • System metrics: CPU, RAM, disk and network I/O
  • Response time: Detailed tracking of LLM times
  • Success rates: Generation quality analysis

๐ŸŽจ Advanced SVG Generation

  • Natural scenes: Landscapes, forests, oceans
  • Geometric elements: Basic and complex shapes
  • Clothing and textiles: Patterns and textures
  • Automatic validation: Valid SVG code verification

๐Ÿ—‚๏ธ Project Structure

gui_simulator/
โ”œโ”€โ”€ ๐Ÿ“ __pycache__/              # Python compiled files
โ”œโ”€โ”€ ๐Ÿ“„ __init__.py               # Package configuration
โ”œโ”€โ”€ ๐Ÿ“„ __main__.py               # Entry point as module
โ”œโ”€โ”€ ๐ŸŽฎ main.py                   # Main application with GUI (998 lines)
โ”œโ”€โ”€ ๐ŸŽจ svg_generator.py          # SVG generator (665 lines)
โ”œโ”€โ”€ ๐Ÿ“Š data_processor.py         # Data processor and analyzer (365 lines)
โ”œโ”€โ”€ โšก performance_analyzer.py   # Performance analyzer (707 lines)
โ”œโ”€โ”€ ๐Ÿค– llm_connector.py          # LLM connectors (494 lines)
โ”œโ”€โ”€ ๐Ÿฆ™ ollama_connector.py       # Specific connector for Ollama
โ”œโ”€โ”€ ๐Ÿงช test_llm_integration.py   # LLM integration tests (175 lines)
โ”œโ”€โ”€ ๐Ÿš€ run.py                    # Alternative execution script
โ”œโ”€โ”€ ๐Ÿ“‹ requirements.txt          # Project dependencies
โ””โ”€โ”€ ๐Ÿ“– README.md                 # Main documentation

โšก Quick Installation

Prerequisites

  • Python 3.8+ (recommended Python 3.9 or higher)
  • Operating system: Windows, macOS, Linux
  • RAM: Minimum 4GB (8GB recommended for LLMs)
  • Disk space: 1GB free

Basic Installation

# 1. Clone the repository
git clone <repository-url>
cd finalDelivery_drawing-with-llms

# 2. Create virtual environment (recommended)
python -m venv venv

# Activate environment (Windows)
venv\Scripts\activate

# Activate environment (Linux/macOS)
source venv/bin/activate

# 3. Install basic dependencies
pip install -r gui_simulator/requirements.txt

# 4. Run automatic installer (optional)
python install.py

LLM Installation

To enable language model capabilities:

# Option 1: OpenAI (requires API key)
pip install openai>=1.3.0
export OPENAI_API_KEY="your-api-key-here"

# Option 2: HuggingFace (local models)
pip install transformers>=4.20.0 torch>=2.0.0

# Option 3: Ollama (recommended for local use)
# Install Ollama from https://ollama.ai
ollama pull llama3.1:8b

๐Ÿš€ Application Usage

Execution

# Method 1: As Python module
python -m gui_simulator

# Method 2: Direct script
python gui_simulator/main.py

# Method 3: Execution script
python gui_simulator/run.py

Programmatic Usage

from gui_simulator.main import DrawingWithLLMsGUI
import tkinter as tk

# Create application
root = tk.Tk()
app = DrawingWithLLMsGUI(root)

# Configure window
root.title("My Drawing with LLMs Simulator")
root.geometry("1400x900")

# Execute
root.mainloop()

๐Ÿ”ง System Components

๐ŸŽจ SVGGenerator (svg_generator.py)

SVG code generator based on text analysis and predefined patterns:

from gui_simulator.svg_generator import SVGGenerator

generator = SVGGenerator()
svg_code = generator.generate_svg("a purple forest at dusk")

Features:

  • โœ… 29+ supported colors
  • โœ… Basic and complex geometric shapes
  • โœ… Natural scenes (forests, oceans, skies)
  • โœ… Clothing and textile elements
  • โœ… Automatic SVG validation

๐Ÿ“Š DataProcessor (data_processor.py)

Advanced processor for text analysis and feature extraction:

from gui_simulator.data_processor import DataProcessor

processor = DataProcessor()
features = processor.extract_features("burgundy corduroy pants")
stats = processor.analyze_dataset(descriptions_list)

Features:

  • โœ… Color and shape extraction
  • โœ… Automatic categorization
  • โœ… Statistical dataset analysis
  • โœ… Complex pattern detection

โšก PerformanceAnalyzer (performance_analyzer.py)

Real-time monitoring system with multi-GPU support:

from gui_simulator.performance_analyzer import PerformanceAnalyzer

analyzer = PerformanceAnalyzer()
analyzer.start_session()
metrics = analyzer.get_real_time_metrics()
gpu_info = analyzer.get_all_gpu_usage()

Monitored metrics:

  • ๐Ÿ–ฅ๏ธ CPU: Percentage usage and cores
  • ๐Ÿ’พ RAM: Current and available usage
  • ๐ŸŽฎ GPU: Usage, memory, temperature (multi-GPU)
  • ๐Ÿ’ฟ Disk: I/O operations per second
  • ๐ŸŒ Network: Inbound and outbound traffic
  • โฑ๏ธ LLM: Specific response times

๐Ÿค– LLMConnector (llm_connector.py)

Unified connector system for different LLM providers:

from gui_simulator.llm_connector import LLMManager

manager = LLMManager()
available = manager.get_available_connectors()  # ['openai', 'ollama']
result = manager.generate_svg_enhanced("a starlit night")

Supported connectors:

  • ๐Ÿค– OpenAI: GPT-3.5-turbo, GPT-4, GPT-4-turbo
  • ๐Ÿค— HuggingFace: T5, FLAN-T5, and seq2seq models
  • ๐Ÿฆ™ Ollama: Llama 3.1, CodeLlama, Mistral

๐Ÿ“ฑ User Interface

Main Control Panel

  • ๐Ÿƒ Run Complete Simulation: Executes complete dataset simulation
  • ๐Ÿ“Š Analyze Dataset: Statistical analysis without generation
  • ๐Ÿ—‘๏ธ Clear Results: Clears results and metrics
  • ๐Ÿ“ค Export Results: Exports results in JSON format
  • ๐Ÿ“ Load Dataset: Loads dataset from CSV/TXT file

Data Input Panel

  • โœ๏ธ Individual description: Field for quick tests
  • ๐Ÿ“ Complete dataset: Editor for multiple descriptions
  • ๐ŸŽฏ Generate SVG: Immediate individual generation

Results Panel

  • ๐ŸŽจ SVG Code: Visualization of generated code
  • ๐Ÿ‘๏ธ Visualize SVG: Preview in web browser
  • ๐Ÿ” Processing analysis: Detailed generation metrics

Real-time Metrics Panel

  • ๐Ÿ“ˆ Processed cases: Counter of processed elements
  • โœ… Success rate: Percentage of successful generations
  • โฑ๏ธ Average LLM time: Specific LLM response time
  • ๐Ÿš€ Throughput: Predictions per second
  • ๐Ÿ–ฅ๏ธ CPU/GPU usage: System resource monitoring

๐Ÿงช Testing and Validation

LLM Testing Script

# Run integration tests
python gui_simulator/test_llm_integration.py

Manual Tests

# Check available connectors
from gui_simulator.llm_connector import LLMManager
manager = LLMManager()
print(manager.get_available_connectors())

# Quick generation test
from gui_simulator.svg_generator import SVGGenerator
generator = SVGGenerator()
svg = generator.generate_svg("a red circle")
print(len(svg))  # Should be > 0

๐Ÿ“„ Data Formats

Dataset Input

CSV format:

id,description
1,"a purple forest at dusk"
2,"gray wool coat with a faux fur collar"

Numbered format:

01. a purple forest at dusk
02. gray wool coat with a faux fur collar
03. a lighthouse overlooking the ocean

Simple text format:

a purple forest at dusk
gray wool coat with a faux fur collar
a lighthouse overlooking the ocean

Results Output

Export JSON:

{
  "timestamp": "2024-07-12T15:30:45",
  "total_cases": 15,
  "summary": {
    "success_rate": 95.5,
    "avg_time": 0.234,
    "avg_elements": 8.2
  },
  "results": [...]
}

โš™๏ธ Advanced Configuration

Environment Variables

# OpenAI
export OPENAI_API_KEY="sk-..."
export OPENAI_ORG_ID="org-..."  # Optional

# HuggingFace
export HF_TOKEN="hf_..."        # Optional for private models

# Ollama
export OLLAMA_HOST="localhost:11434"  # Customize host

GPU Configuration

The system automatically detects available GPUs. For manual configuration:

# In performance_analyzer.py
analyzer = PerformanceAnalyzer()
analyzer.primary_gpu_index = 1  # Use second GPU as primary

๐Ÿ“Š Performance Metrics

Typical Benchmarks

Mode Time/case Throughput SVG Quality
Traditional generator ~0.050s 20 pred/s Basic
OpenAI GPT-3.5 ~0.800s 1.25 pred/s High
Ollama Llama3.1:8b ~2.500s 0.4 pred/s Medium-High
HuggingFace T5 ~1.200s 0.83 pred/s Medium

System Requirements by Mode

Mode Minimum RAM Recommended GPU CPU
Traditional 2GB Not required Dual-core
OpenAI 4GB Not required Dual-core
Ollama 8GB 6GB VRAM Quad-core
HuggingFace 12GB 8GB VRAM Quad-core

๐Ÿ” Troubleshooting

Common Issues

Error: "No module named 'gui_simulator'"

# Make sure you're in the correct directory
cd finalDelivery_drawing-with-llms
python -m gui_simulator

Error: "LLM Not Available"

# Check installation
pip list | grep -E "openai|transformers|torch"

# Check Ollama
ollama list

Low GPU performance

# Check drivers
nvidia-smi

# Check PyTorch GPU
python -c "import torch; print(torch.cuda.is_available())"

Debug Logs

# Enable detailed logs
import logging
logging.basicConfig(level=logging.DEBUG)

๐Ÿ‘ฅ Development Team

This project was developed by students from Universidad Distrital Francisco Josรฉ de Caldas as part of their academic work in artificial intelligence and natural language processing:

Developer Email Role
Nelson David Posso Suarez ndpossos@udistrital.edu.co System Architecture & LLM Integration
Edward Julian Garcia Gaitan ejgarciag@udistrital.edu.co GUI Development & Performance Analysis
Jaider Camilo Carvajal Marin jccarvajalm@udistrital.edu.co SVG Generation & Data Processing

๐ŸŽ“ Academic Institution

Universidad Distrital Francisco Josรฉ de Caldas

  • Faculty of Engineering
  • Systems Engineering Program
  • Research line: Artificial Intelligence and Machine Learning

๏ฟฝ Project Documentation

This repository includes comprehensive documentation about the project's development, methodology, and results:

Document Description Link
IEEE Paper Academic paper in IEEE format detailing the project methodology and results Final_Project_Paper_IEEE.pdf
Technical Report Complete technical report with implementation details and analysis Final_Project_Technical_Report.pdf
Project Presentation Presentation slides with project overview and demonstrations Final_Project_Presentation.pdf
Poster Academic poster summarizing the project findings and contributions Final_Project_Poster.pdf

๐Ÿ“– Documentation Content

  • Methodology: Detailed explanation of the LLM integration approach
  • Implementation: Technical details of the GUI simulator and SVG generation
  • Evaluation: Performance analysis and comparison with baseline methods
  • Results: Statistical analysis of generation quality and system performance
  • Future Work: Proposed improvements and research directions

๏ฟฝ๐Ÿ“‹ Dependencies

Main Dependencies

pandas>=2.0.0          # Data processing
numpy>=1.20.0          # Numerical operations
requests>=2.28.0       # HTTP communication
defusedxml>=0.7.0      # Secure XML/SVG validation
matplotlib>=3.5.0      # Optional visualizations
psutil>=5.9.0          # System monitoring

Optional LLM Dependencies

openai>=1.3.0          # OpenAI GPT-3.5/4
transformers>=4.20.0   # HuggingFace models
torch>=2.0.0           # PyTorch for HF
requests>=2.28.0       # Ollama HTTP API
GPUtil>=1.4.0          # Advanced GPU monitoring

Development Dependencies

pytest>=7.0.0          # Testing framework
black>=22.0.0          # Code formatter
flake8>=5.0.0          # Linting
mypy>=1.0.0            # Type checking

๐Ÿ—๏ธ Technical Architecture

Design Pattern

The simulator implements a modular architecture based on the Strategy pattern for LLM connectors and Observer for real-time metrics:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   GUI Main      โ”‚โ”€โ”€โ”€โ–ถโ”‚  LLM Manager    โ”‚โ”€โ”€โ”€โ–ถโ”‚  LLM Connectors โ”‚
โ”‚   (Controller)  โ”‚    โ”‚   (Strategy)    โ”‚    โ”‚   (Strategies)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                        โ”‚
         โ–ผ                        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Performance     โ”‚    โ”‚ SVG Generator   โ”‚
โ”‚ Analyzer        โ”‚    โ”‚ & Processor     โ”‚
โ”‚ (Observer)      โ”‚    โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Threading Model

  • Main Thread: GUI and user events
  • Worker Thread: Simulations and heavy processing
  • Metrics Thread: System metrics collection
  • LLM Thread: External API calls (non-blocking)

๐Ÿ”„ Processing Lifecycle

graph TD
    A[Text Input] --> B{LLM Available?}
    B -->|Yes| C[LLM Analysis]
    B -->|No| D[Traditional Analysis]
    C --> E[Enhanced SVG Generation]
    D --> F[Basic SVG Generation]
    E --> G[SVG Validation]
    F --> G
    G --> H[Metrics & Report]
    H --> I[Visualization]
Loading

๐Ÿ“Š Use Cases

1. Academic Research

  • Comparison of generation techniques
  • SVG quality analysis
  • LLM model benchmarking

2. Model Development

  • Rapid prototyping
  • Hypothesis validation
  • Prompt experimentation

3. Kaggle Competition

  • Submission generation
  • Dataset analysis
  • Performance optimization

4. Education

  • LLM concept demonstration
  • NLP processing visualization
  • Interactive learning

๐Ÿ”ฎ Future Improvements

Planned Features

  • Support for more LLMs: Claude, Gemini, Cohere
  • Integrated SVG editor: Direct visual modification
  • Batch processing: Optimized massive processing
  • Advanced metrics: Semantic quality, diversity
  • REST API: External programmatic access
  • Docker support: Complete containerization

Technical Optimizations

  • Intelligent caching: LLM response cache
  • Parallelization: Multi-core processing
  • Streaming: Real-time LLM responses
  • Compression: Generated SVG optimization

๐Ÿ“œ License

MIT License

Copyright (c) 2024 Universidad Distrital Francisco Josรฉ de Caldas
Drawing with LLMs Project Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

๐Ÿ“ž Support and Contact

For Technical Issues

  • ๐Ÿ› Bugs: Use the repository issue system
  • ๐Ÿ’ก Feature requests: GitHub Discussions
  • ๐Ÿ“– Documentation: Project Wiki

Academic Contact

Community

  • ๐Ÿ’ฌ Discord: Project channel (coming soon)
  • ๐Ÿ“บ YouTube: Tutorials and demonstrations
  • ๐Ÿ“ฐ Blog: Project updates

โญ If you find this project useful, don't forget to give it a star on GitHub โญ

Developed with โค๏ธ by the Drawing with LLMs team
Universidad Distrital Francisco Josรฉ de Caldas - 2024

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages