Spaces:
Runtime error
Runtime error
Update app.py
Browse files285 unmodified lines286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327285 unmodified linesnumbered_output = "\n".join([f"{key}: {value}" for key, value in attributes.items()])return f"Extracted Text:\n{extracted_text}\n\nAttributes and Values:\n{numbered_output}", message# HTML content for camera functionalitycamera_html = """<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Camera for Text Scanning</title><style>#video {width: 100%;height: auto;}canvas {display: none; /* Hide the canvas, only used for capturing the image */}</style></head><body><h1>Camera for Text Scanning</h1><video id="video" autoplay playsinline></video><button id="switchCameraButton">Switch Camera</button><button id="captureButton">Capture Image</button><canvas id="canvas"></canvas><script src="camera.js"></script></body></html>"""The HTML code in your script under the camera_html variable is a standalone HTML page. However, this HTML code does not directly integrate with the Gradio interface in your Python application.Why the camera_html code won't work as-is:Gradio and HTML: Gradio is designed to build interfaces using Python objects like gr.Interface. It does not directly interpret raw HTML code in the way a traditional web server would.JavaScript Execution: The <script src="camera.js"></script> in your camera_html will not run as part of the Gradio application because Gradio does not serve static files (like camera.js) or allow embedding custom JavaScript directly.if __name__ == "__main__":app().launch(share=True)285 unmodified lines286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330285 unmodified linesnumbered_output = "\n".join([f"{key}: {value}" for key, value in attributes.items()])return f"Extracted Text:\n{extracted_text}\n\nAttributes and Values:\n{numbered_output}", message# Gradio Interfacedef app():df = format_salesforce_data()table_component = Nonebar_graph_component = Noneif df is not None:table_component = df.to_html(index=False)bar_graph_image = generate_bar_graph(df)if bar_graph_image:bar_graph_component = bar_graph_imagereturn gr.TabbedInterface([gr.Interface(fn=process_image,inputs=[gr.Image(type="numpy", label="Upload Image"),gr.Dropdown(label="Mode", choices=["Entry", "Exit"], value="Entry"),gr.Radio(label="Entry Type", choices=["Sales", "Non-Sales"], value="Sales"),gr.Number(label="Quantity", value=1, interactive=True),],outputs=[gr.Text(label="Image Data Viewer"),gr.Text(label="Result")],title="Salesforce Export",description="Upload an image, select Entry/Exit mode and Sales/Non-Sales type, and specify quantity."),gr.Interface(fn=lambda: (table_component, bar_graph_component),inputs=[],outputs=[gr.HTML(label="Salesforce Data Table"),gr.Image(type="pil", label="Stock Distribution Bar Graph")],title="Salesforce Data",description="View structured Salesforce data as a table and bar graph.")], ["Processing", "Salesforce Data"])if __name__ == "__main__":app().launch(share=True)
app.py+40-37