Skip to content

Commit

Permalink
Merge branch 'mkolomeychenko-patch-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mkolomeychenko committed Sep 23, 2020
2 parents 351b8c9 + 9c21741 commit 6aebdd2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
# classes-stats-for-images
<div align="center" markdown>

<img src="https://i.imgur.com/UdBujFN.png" width="250" /> <br>

<img src="https://i.imgur.com/vhrUP20.png" width="100"/>

# Classes stats for images

<p align="center">

<a href="#overview">Overview</a> •
<a href="#description">Description</a> •
<a href="#installation">Installation</a> •
<a href="#how-to-use">How to use</a>
</p>

[![](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://supervise.ly/slack)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/supervisely-ecosystem/classes-stats-for-images)

![](http://img.shields.io/endpoint?color=success&label=views&url=https%3A%2F%2Fdev.supervise.ly%2Fpublic%2Fapi%2Fv3%2Fecosystem.counters%3Frepo%3Dsupervisely-ecosystem%2Fclasses-stats-for-images%26counter%3Dviews)
![](http://img.shields.io/endpoint?color=success&label=used%20by%20teams&url=https%3A%2F%2Fdev.supervise.ly%2Fpublic%2Fapi%2Fv3%2Fecosystem.counters%3Frepo%3Dsupervisely-ecosystem%2Fclasses-stats-for-images%26counter%3Druns)
![](http://img.shields.io/endpoint?color=success&label=runs&url=https%3A%2F%2Fdev.supervise.ly%2Fpublic%2Fapi%2Fv3%2Fecosystem.counters%3Frepo%3Dsupervisely-ecosystem%2Fclasses-stats-for-images%26counter%3Ddownloads)




</div>

Report gives detailed statistics for all classes in images project
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"target": ["images_project", "images_dataset"],
"context_root": "Report"
},
"icon": "https://img.icons8.com/fluent/96/000000/combo-chart.png"
"icon": "https://img.icons8.com/fluent/96/000000/combo-chart.png",
"icon_background": "#FFFFFF"
}
2 changes: 1 addition & 1 deletion debug.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ context.teamId=1
context.workspaceId=151
context.userLogin="max"
modal.state.slyProjectId=355
modal.state.samplePercent=100
modal.state.samplePercent=1
#197 - pascal

SERVER_ADDRESS="put your value here"
Expand Down
9 changes: 6 additions & 3 deletions src/classes_stats_for_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def sample_images(api, datasets):
def calc(api: sly.Api, task_id, context, state, app_logger):
global progress, sum_class_area_per_image, sum_class_count_per_image, count_images_with_class

workspace = api.workspace.get_info_by_id(WORKSPACE_ID)
project = None
datasets = None
if DATASET_ID is not None:
Expand Down Expand Up @@ -264,13 +265,14 @@ def calc(api: sly.Api, task_id, context, state, app_logger):
overviewTable["data"] = _overview_data

# save report to file *.lnk (link to report)
report_name = "{}_{}_(id_{}).lnk".format(time.strftime("%Y-%m-%d-%H:%M:%S"), project.name, project.id)
report_name = "{}.lnk".format(project.name)
local_path = os.path.join(my_app.data_dir, report_name)
sly.fs.ensure_base_path(local_path)
with open(local_path, "w") as text_file:
print(my_app.app_url, file=text_file)
remote_path = "/reports/classes_stats/{}/{}".format(USER_LOGIN, report_name)
api.file.upload(TEAM_ID, local_path, remote_path)
remote_path = "/reports/classes_stats/{}/{}/{}".format(USER_LOGIN, workspace.name, report_name)
remote_path = api.file.get_free_name(TEAM_ID, remote_path)
file_info = api.file.upload(TEAM_ID, local_path, remote_path)

fields = [
{"field": "data.overviewTable", "payload": overviewTable},
Expand All @@ -285,6 +287,7 @@ def calc(api: sly.Api, task_id, context, state, app_logger):
{"field": "data.savePath", "payload": remote_path},
]
api.task.set_fields(task_id, fields)
api.task.set_output_report(task_id, file_info["id"], report_name)


def main():
Expand Down

0 comments on commit 6aebdd2

Please sign in to comment.