Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions src/ac_training_lab/bambu_a1mini/class_demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 3D Print Quality Measurement Demo\n",
"\n",
"This notebook demonstrates how to measure and evaluate 3D print quality using our measurement system.\n",
"\n",
"## Overview\n",
"\n",
"### Input Parameters\n",
"- **Nozzle Temperature** (180-250°C): Temperature of the printing nozzle\n",
"- **Print Speed** (20-150 mm/s): Movement speed of the print head\n",
"- **Layer Height** (0.1-0.4 mm): Height of each printed layer\n",
"- **Flow Rate** (90-110%): Material extrusion rate\n",
"- **Retraction Distance** (0-10 mm): Length of filament retraction\n",
"- **Fan Speed** (0-100%): Cooling fan speed\n",
"\n",
"### Output Measurements\n",
"- **Print Quality Score**: Measures surface quality, edge precision, and defect analysis\n",
"- **Speed Score**: Evaluates time efficiency of the print\n",
"- **Material Efficiency Score**: Measures material usage optimization\n",
"- **Total Performance Score**: Combined evaluation of all metrics"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Install required packages\n",
"!pip install requests pillow numpy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
"from PIL import Image\n",
"import numpy as np\n",
"\n",
"# Hugging Face Space API endpoint\n",
"API_URL = \"https://your-space-url/api\" # Will be provided by instructor\n",
"\n",
"def evaluate_print(image_path, parameters):\n",
" \"\"\"Evaluate print quality using the measurement system\n",
" \n",
" Args:\n",
" image_path (str): Path to the print image\n",
" parameters (dict): Printing parameters\n",
" \n",
" Returns:\n",
" dict: Measurement scores\n",
" \"\"\"\n",
" # Load and prepare image\n",
" with open(image_path, 'rb') as f:\n",
" image_data = f.read()\n",
" \n",
" # Prepare request data\n",
" files = {'image': image_data}\n",
" data = {'parameters': json.dumps(parameters)}\n",
" \n",
" # Send request to API\n",
" response = requests.post(f\"{API_URL}/evaluate\", files=files, data=data)\n",
" \n",
" return response.json()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Usage\n",
"\n",
"Let's try evaluating a print with some example parameters:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Example parameters\n",
"test_parameters = {\n",
" 'nozzle_temp': 200,\n",
" 'print_speed': 60,\n",
" 'layer_height': 0.2,\n",
" 'flow_rate': 100,\n",
" 'retraction_distance': 5,\n",
" 'fan_speed': 100\n",
"}\n",
"\n",
"# Evaluate print (replace with your image path)\n",
"results = evaluate_print('your_print_image.jpg', test_parameters)\n",
"\n",
"# Display results\n",
"print(\"Measurement Results:\")\n",
"print(f\"Print Quality Score: {results['quality']:.4f}\")\n",
"print(f\"Speed Score: {results['speed']:.4f}\")\n",
"print(f\"Material Efficiency Score: {results['material']:.4f}\")\n",
"print(f\"Total Performance Score: {results['total']:.4f}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"\n",
"Now it's your turn! Try different parameter combinations and analyze how they affect the measurement scores.\n",
"\n",
"1. What parameters seem to have the biggest impact on print quality?\n",
"2. Can you find parameters that give good scores across all metrics?\n",
"3. What happens when you use extreme parameter values?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Your experiments here\n",
"your_parameters = {\n",
" 'nozzle_temp': 0, # Replace with your value\n",
" 'print_speed': 0, # Replace with your value\n",
" 'layer_height': 0, # Replace with your value\n",
" 'flow_rate': 0, # Replace with your value\n",
" 'retraction_distance': 0, # Replace with your value\n",
" 'fan_speed': 0 # Replace with your value\n",
"}\n",
"\n",
"# Run your evaluation\n",
"# results = evaluate_print('your_image.jpg', your_parameters)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
}
}
Loading