-
Notifications
You must be signed in to change notification settings - Fork 0
/
TecDoc_Shiny.qmd
65 lines (42 loc) · 3.26 KB
/
TecDoc_Shiny.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: "User Guide"
subtitle: "for Image Clustering and Analysis in Shiny"
author: <div><a href="https://github.com/TheArmbreaker" target="_blank"><img src="https://img.shields.io/badge/Github-Markus%20Armbrecht-orange" alt="Github Markus Armbrecht"></a></div>
date: "`r Sys.Date()`"
format:
html:
page-layout: article
toc: false
link-external-newwindow: true
editor: source
---
This document covers basics features to use the deployed app and also highlights very specific codeing challenges.
Code which is deemed to be not very surprising is commented in the source code of app.R.
The template / theme for the shiny app was provided by the [Data Professor](http://github.com/dataprofessor) and Winston Chang on Github and further modified by myself.
## Loading Data and Model
The data is loaded from the model results, which are stored in CSV-files.
Based on the selection the csv-file is loaded.
The options with _predict reflect the results from the recipe-workflow. Those without are the results from Base R code.
- Flowers
- Weapons
- Flowers_predict
- Weapons_predict
To load the model for prediction the selection is used. As the baseR-model is not deployed, the model is loaded based on the substring before "_predict".
## Loading Images
The images are loaded with an ObserveEvent-function - either based on a cluster-prediction or cluster-selection. Based on the requested cluster four random files are sampled and rendered.
Code for loading and displaying images is separated from each another to prevent images from overlapping and contain the output in a div-container.
The loading function uses local() to render each image in a separate environment and append it to the server-output. The output will then be displayed via a renderUI-function that utilizes the outputImage() function.
This very specific solution is based on this [Stackoverflow](https://stackoverflow.com/a/69400158/19730678) post. It was re-designed with lists and other approaches, but turned out to be the only working approach.
Therin the local() function is key to success for the rendering. If this is not used, the [[output]] will be overwritten and the same image is displayed four times. Further details on the local() function can be found in this post on [Stackoverflow](https://stackoverflow.com/a/10904810/19730678).
## Cluster New Images
The page to cluster images enables the upload of new pictures and prediction of a cluster. Only .png and .jpg files can be uploaded.
The prediction will use a reactiveValue for displaying example images of the predicted cluster.
## Show Clusters
The show clusters page enables the investigation of cluster content.
The displayed images depend on the selected cluster. This also shows Base R results to explore differences.
Furthermore the cluster can be labeled with a name. This string is a dummy and might be connected to an sql database for actually storing the input.
## Dataset
- Weapons in Images on [kaggle.com](https://www.kaggle.com/datasets/jubaerad/weapons-in-images-segmented-videos)
- Flower Color Images on [kaggle.com](https://www.kaggle.com/datasets/olgabelitskaya/flower-color-images)
## Models
Download the RDS files from [GoogleDrive](https://drive.google.com/drive/folders/1LQ2Ixx4rwxcAW8TQPocOXQnUKcDCvBSE?usp=share_link)