My first dash with Python in Shiny

Hi Everyone!!

I want to create my first dashboard in Shiny in Rstudio using Python. The objective is to deploy a TensorFlow model inside a Shiny app. We will build a model that can classify insects in images; then, we will build a Shiny app that lets you upload an image and get predictions from this model.
My idea is to create a dashboard that uses a training neural network (Yolov5) (model = '' ) to identify the targets with a bounding box in a JPG image chosen.
But, I had mixed feelings about what must be R or Python in my code. My idea to create a dashboard that uses a training neural network (Yolov5) to identify the targets with bounding-box in an image chosen.
I try to draft this:

from shiny import UI
from yolo_v5_inference import Inference
from PIL import Image as view
from IPython.display import Image


# Load the model
model = '' # Better model trains using Yolov5 neural network in Python

# Define the UI
ui <- fluidPage(
  # App title ----
  titlePanel("Hello TensorFlow!"),
  # Sidebar layout with input and output definitions ----
    # Sidebar panel for inputs ----
      # Input: File upload
      fileInput("image_path", label = "Input a JPEG image")
    # Main panel for displaying outputs ----
      # Output: 
      textOutput(outputId = "prediction"),
      plotOutput(outputId = "image")

# Define server logic required to draw a histogram ----
server <- function(input, output) {
  image <- reactive({
  output$prediction <- renderText({
    img <- image() %>% 
      array_reshape(., dim = c(1, dim(.), 1))
    standart = Inference(crops_path=imgage, yolov5_model_path=model, conf_threshold=0.5, rescale=(1.5, 1.5), save_rescaled=True)
    paste0("The predicted bounding-box ")
  output$image <- renderPlot({

shinyApp(ui, server)

Please, any help with it?

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.