Update app.py
Browse files
app.py
CHANGED
|
@@ -1268,8 +1268,7 @@ with gr.Blocks(title="Makerspace Inventory System", css=CUSTOM_CSS) as demo:
|
|
| 1268 |
height=400
|
| 1269 |
)
|
| 1270 |
|
| 1271 |
-
|
| 1272 |
-
load_example_checkout_btn = gr.Button("📸 Load Example", size="sm", variant="secondary", scale=0)
|
| 1273 |
|
| 1274 |
with gr.Column(scale=1):
|
| 1275 |
gr.Markdown("""
|
|
@@ -1364,8 +1363,7 @@ with gr.Blocks(title="Makerspace Inventory System", css=CUSTOM_CSS) as demo:
|
|
| 1364 |
|
| 1365 |
receipt_file = gr.File(label="Upload Receipt (PDF or Image)", file_types=[".pdf", ".png", ".jpg", ".jpeg"])
|
| 1366 |
|
| 1367 |
-
|
| 1368 |
-
load_example_receipt_btn = gr.Button("📄 Load Example", size="sm", variant="secondary", scale=0)
|
| 1369 |
|
| 1370 |
receipt_status = gr.Markdown("")
|
| 1371 |
|
|
@@ -1740,29 +1738,32 @@ with gr.Blocks(title="Makerspace Inventory System", css=CUSTOM_CSS) as demo:
|
|
| 1740 |
)
|
| 1741 |
|
| 1742 |
# EXAMPLE INPUTS
|
| 1743 |
-
|
| 1744 |
-
|
| 1745 |
-
|
| 1746 |
return Image.open(EXAMPLE_CHECKOUT_IMAGE)
|
| 1747 |
-
|
| 1748 |
-
|
| 1749 |
-
|
| 1750 |
-
|
| 1751 |
-
|
| 1752 |
-
|
| 1753 |
-
|
|
|
|
| 1754 |
|
| 1755 |
-
|
| 1756 |
-
|
| 1757 |
-
|
| 1758 |
return EXAMPLE_RECEIPT_PDF
|
| 1759 |
-
|
| 1760 |
-
|
| 1761 |
-
|
| 1762 |
-
|
| 1763 |
-
|
| 1764 |
-
|
| 1765 |
-
|
|
|
|
| 1766 |
|
| 1767 |
if __name__ == "__main__":
|
| 1768 |
-
demo.
|
|
|
|
|
|
| 1268 |
height=400
|
| 1269 |
)
|
| 1270 |
|
| 1271 |
+
load_example_checkout_btn = gr.Button("📸 Load Example", size="sm", variant="secondary", scale=0, visible=EXAMPLE_CHECKOUT_IMAGE is not None)
|
|
|
|
| 1272 |
|
| 1273 |
with gr.Column(scale=1):
|
| 1274 |
gr.Markdown("""
|
|
|
|
| 1363 |
|
| 1364 |
receipt_file = gr.File(label="Upload Receipt (PDF or Image)", file_types=[".pdf", ".png", ".jpg", ".jpeg"])
|
| 1365 |
|
| 1366 |
+
load_example_receipt_btn = gr.Button("📄 Load Example", size="sm", variant="secondary", scale=0, visible=EXAMPLE_RECEIPT_PDF is not None)
|
|
|
|
| 1367 |
|
| 1368 |
receipt_status = gr.Markdown("")
|
| 1369 |
|
|
|
|
| 1738 |
)
|
| 1739 |
|
| 1740 |
# EXAMPLE INPUTS
|
| 1741 |
+
def load_checkout_example():
|
| 1742 |
+
try:
|
| 1743 |
+
if EXAMPLE_CHECKOUT_IMAGE:
|
| 1744 |
return Image.open(EXAMPLE_CHECKOUT_IMAGE)
|
| 1745 |
+
except:
|
| 1746 |
+
pass
|
| 1747 |
+
return None
|
| 1748 |
+
|
| 1749 |
+
load_example_checkout_btn.click(
|
| 1750 |
+
fn=load_checkout_example,
|
| 1751 |
+
outputs=[checkout_image]
|
| 1752 |
+
)
|
| 1753 |
|
| 1754 |
+
def load_receipt_example():
|
| 1755 |
+
try:
|
| 1756 |
+
if EXAMPLE_RECEIPT_PDF:
|
| 1757 |
return EXAMPLE_RECEIPT_PDF
|
| 1758 |
+
except:
|
| 1759 |
+
pass
|
| 1760 |
+
return None
|
| 1761 |
+
|
| 1762 |
+
load_example_receipt_btn.click(
|
| 1763 |
+
fn=load_receipt_example,
|
| 1764 |
+
outputs=[receipt_file]
|
| 1765 |
+
)
|
| 1766 |
|
| 1767 |
if __name__ == "__main__":
|
| 1768 |
+
demo.queue()
|
| 1769 |
+
demo.launch()
|