zacbouhnik commited on
Commit
413a772
1 Parent(s): fe0f7a9

added title and examples to the UI

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -13,9 +13,21 @@ classif_pipeline = pipeline(
13
  "image-classification", model=classif_model, feature_extractor=feature_extractor
14
  )
15
 
 
 
 
 
 
 
 
 
 
16
  demo = gr.Interface(
17
- fn=lambda x: classif_pipeline(x)[0]["label"],
18
  inputs=gr.Image(type="pil"),
19
  outputs="text",
 
 
 
20
  )
21
- demo.launch()
 
13
  "image-classification", model=classif_model, feature_extractor=feature_extractor
14
  )
15
 
16
+ OUTPUT_SENTENCE = "This image is {result}."
17
+
18
+
19
+ def get_formatted_prediction(img) -> str:
20
+ return OUTPUT_SENTENCE.format(
21
+ result=classif_pipeline(img)[0]["label"].replace("-", " ")
22
+ )
23
+
24
+
25
  demo = gr.Interface(
26
+ fn=get_formatted_prediction,
27
  inputs=gr.Image(type="pil"),
28
  outputs="text",
29
+ title="ImageIN",
30
+ description="Identify illustrations in pages of historical books!",
31
+ examples=["old_book_page.png", "women_book_image.png", "page_with_images.png"],
32
  )
33
+ demo.launch()