VoVanPhuc commited on
Commit
382d5fa
·
verified ·
1 Parent(s): 60a37f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -3,7 +3,9 @@ import requests
3
  from io import BytesIO
4
  import os
5
 
6
- def call_predict_api(image):
 
 
7
  # Convert PIL images to base64 string
8
  src_buffer = BytesIO()
9
  image.save(src_buffer, format='PNG')
@@ -31,9 +33,15 @@ if __name__ == "__main__":
31
  width=512,
32
  height=512,
33
  ),
 
 
 
 
 
 
34
  ],
35
  outputs=[gr.Markdown(label="Result")],
36
  title="BBC-OCR",
37
  description="A simple OCR tool to extract text from images.",
38
  )
39
- iface.launch(auth=[(os.environ["username"], os.environ["password"])], show_api=False, share=True)
 
3
  from io import BytesIO
4
  import os
5
 
6
+ def call_predict_api(image, private_key=None):
7
+ if private_key != os.environ["api_key"]:
8
+ return "Invalid API key. Please check your key and try again."
9
  # Convert PIL images to base64 string
10
  src_buffer = BytesIO()
11
  image.save(src_buffer, format='PNG')
 
33
  width=512,
34
  height=512,
35
  ),
36
+ gr.Textbox(
37
+ label="private-key",
38
+ placeholder="Enter your private key",
39
+ type="password",
40
+ lines=1,
41
+ ),
42
  ],
43
  outputs=[gr.Markdown(label="Result")],
44
  title="BBC-OCR",
45
  description="A simple OCR tool to extract text from images.",
46
  )
47
+ iface.launch(show_api=False)