Glainez commited on
Commit
f42cf88
1 Parent(s): 5419a54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -20
app.py CHANGED
@@ -1,29 +1,26 @@
1
  import gradio as gr
2
  import requests
3
  from AuthVerification import auth_verification
 
4
 
5
- title = "Minimalistic Scanner, by Proppos"
6
 
7
- custom_html = """
8
- <script>
9
- const originalGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- navigator.mediaDevices.getUserMedia = (constraints) => {
12
- if (!constraints.video.facingMode) {
13
- constraints.video.facingMode = {ideal: "environment"};
14
- }
15
- return originalGetUserMedia(constraints);
16
- };
17
- </script>
18
- """
19
 
20
- def instant_predict(pil_image):
21
- """
22
- Request
23
- """
24
- print('Sending image to Proppos ...')
25
- return 'nice'
26
-
27
  def display_outputs(input_image):
28
  try:
29
  instant_predict(input_image)
@@ -31,7 +28,7 @@ def display_outputs(input_image):
31
  except Exception as e:
32
  return f"Error: {e}"
33
 
34
- with gr.Blocks(title=title, theme='huggingface', head=custom_html) as demo_app:
35
  with gr.Column():
36
  input_image = gr.Image(type='pil', label='TAKE A PICTURE OF THE TRAY', sources=['webcam'])
37
  output_comments = gr.Textbox(label='Comments')
 
1
  import gradio as gr
2
  import requests
3
  from AuthVerification import auth_verification
4
+ from MinimalScanner import instant_predict
5
 
6
+ title = "Minimal Scanner, by Proppos"
7
 
8
+ def js_to_prefere_the_back_camera_of_mobilephones():
9
+ custom_html = """
10
+ <script>
11
+ const originalGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
12
+
13
+ navigator.mediaDevices.getUserMedia = (constraints) => {
14
+ if (!constraints.video.facingMode) {
15
+ constraints.video.facingMode = {ideal: "environment"};
16
+ }
17
+ return originalGetUserMedia(constraints);
18
+ };
19
+ </script>
20
+ """
21
+ return custom_html
22
 
 
 
 
 
 
 
 
 
23
 
 
 
 
 
 
 
 
24
  def display_outputs(input_image):
25
  try:
26
  instant_predict(input_image)
 
28
  except Exception as e:
29
  return f"Error: {e}"
30
 
31
+ with gr.Blocks(title=title, theme='huggingface', head=js_to_prefere_the_back_camera_of_mobilephones()) as demo_app:
32
  with gr.Column():
33
  input_image = gr.Image(type='pil', label='TAKE A PICTURE OF THE TRAY', sources=['webcam'])
34
  output_comments = gr.Textbox(label='Comments')