Skip to content

Commit

Permalink
Merge pull request #10 from FocoosAI/demo
Browse files Browse the repository at this point in the history
feat: add demo notebooks
  • Loading branch information
giuseppeambrosio97 authored Dec 10, 2024
2 parents edebe02 + be4c73a commit 143a5c4
Show file tree
Hide file tree
Showing 8 changed files with 635 additions and 86 deletions.
80 changes: 80 additions & 0 deletions demo/dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
DATASETS = {
"bottles": {
"name": "bottles",
"path": "../data/bottles",
"task": "detection",
"workspace": "roboflow-100",
"project": "soda-bottles",
"version": 4,
},
"blister": {
"name": "blister",
"path": "../data/blister",
"task": "instance_segmentation",
"workspace": "blisterdetection",
"project": "blister-pills-segmentation",
"version": 1,
},
"boxes": {
"name": "boxes",
"path": "../data/boxes",
"task": "detection",
"workspace": "moyed-chowdhury",
"project": "mv_train_data",
"version": 2,
},
"cable": {
"name": "cable",
"path": "../data/cable",
"task": "detection",
"workspace": "roboflow-100",
"project": "cable-damage",
"version": 2,
},
"concrete": {
"name": "concrete",
"path": "../data/concrete",
"task": "instance_segmentation",
"workspace": "focoosai",
"project": "concrete-merge-d91ow",
"version": 1,
},
"lettuce": {
"name": "lettuce",
"path": "../data/lettuce",
"task": "detection",
"workspace": "object-detection",
"project": "lettuce-pallets",
"version": 1,
},
"peanuts": {
"name": "Peanuts",
"path": "../data/peanuts",
"task": "detection",
"workspace": "roboflow-100",
"project": "peanuts-sd4kf",
"version": 1,
},
"safety": {
"name": "Safety",
"path": "../data/safety",
"task": "detection",
"workspace": "roboflow-100",
"project": "construction-safety-gsnvb",
"version": 1,
},
"strawberry": {
"name": "Strawberries",
"path": "../data/strawberries",
"task": "instance_segmentation",
"workspace": "marstrawberry",
"project": "strawberry-disease-uudgf",
"version": 1,
},
}


def get_dataset(name):
if name not in DATASETS:
raise ValueError(f"Dataset {name} not found")
return DATASETS[name]
102 changes: 102 additions & 0 deletions demo/datasets.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Links:\n",
"## Detection\n",
"- [x] [Bottles in Fridge](https://universe.roboflow.com/roboflow-100/soda-bottles/dataset)\n",
"- [x] [Box on Conveyor](https://universe.roboflow.com/moyed-chowdhury/mv_train_data/dataset/2)\n",
"- [x] [Cable Defects](https://universe.roboflow.com/roboflow-100/cable-damage/dataset/2)\n",
"- [x] [Lattuce Growth](https://universe.roboflow.com/object-detection/lettuce-pallets/dataset)\n",
"- [x] [Peanuts Quality Control](https://universe.roboflow.com/roboflow-100/peanuts-sd4kf)\n",
"- [x] [Safety in Workplace](https://universe.roboflow.com/roboflow-100/construction-safety-gsnvb)\n",
"\n",
"## Segmentation\n",
"- [x] [Blister and Pills](https://universe.roboflow.com/blisterdetection/blister-pills-segmentation/dataset)\n",
"- [x] [Concrete Cracks and Defects](https://app.roboflow.com/focoosai/concrete-merge-d91ow/)\n",
"- [x] [Strawberry Harvest](https://universe.roboflow.com/marstrawberry/strawberry-disease-uudgf/dataset/13)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Download datasets\n",
"# !pip install roboflow\n",
"from dataset import get_dataset\n",
"from roboflow import Roboflow\n",
"import os\n",
"\n",
"dataset_cfg = get_dataset(\"bottles\")\n",
"\n",
"rf = Roboflow(api_key=os.getenv(\"ROBOFLOW_API_KEY\"))\n",
"project = rf.workspace(dataset_cfg[\"workspace\"]).project(dataset_cfg[\"project\"])\n",
"version = project.version(dataset_cfg[\"version\"])\n",
"dataset = version.download(\"coco\", location=dataset_cfg[\"path\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from utils import display_instseg, display_detection\n",
"from dataset import get_dataset\n",
"\n",
"dataset_cfg = get_dataset(\"bottles\")\n",
"PATH = dataset_cfg[\"path\"] + \"/valid\"\n",
"\n",
"if dataset_cfg[\"task\"] == \"instance_segmentation\":\n",
" display_instseg(PATH, num_images=4, annotate=True)\n",
"else:\n",
" display_detection(PATH, num_images=4, annotate=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from focoos import Focoos, FocoosEnvHostUrl\n",
"\n",
"focoos = Focoos(api_key=os.getenv(\"FOCOOS_API_KEY\"), host_url=FocoosEnvHostUrl.DEV)\n",
"focoos.list_shared_datasets()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "focoos",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 143a5c4

Please sign in to comment.