Spaces:
Paused
Paused
for log, one output simplified
Browse files
app.py
CHANGED
@@ -43,8 +43,18 @@ tax_deductions = '''Extract the following information in the given format:
|
|
43 |
}
|
44 |
'''
|
45 |
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
{
|
49 |
"role": "user",
|
50 |
"content": [
|
@@ -92,27 +102,11 @@ def demo(image_path, prompt):
|
|
92 |
json = literal_eval(almost_json)
|
93 |
except:
|
94 |
json = output_text[0] # Return raw output if JSON parsing fails
|
95 |
-
return json
|
96 |
-
|
97 |
-
def process_document(image):
|
98 |
-
# Save the uploaded image to a temporary file
|
99 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as tmp_file:
|
100 |
-
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
101 |
-
image.save(tmp_file.name) # Save the image to the temporary file
|
102 |
-
image_path = tmp_file.name # Get the path of the saved file
|
103 |
-
|
104 |
-
# Process the image with your model
|
105 |
-
one = demo(image_path, other_benifits)
|
106 |
-
two = demo(image_path, tax_deductions)
|
107 |
-
json_op = {
|
108 |
-
"tax_deductions": one,
|
109 |
-
"other_benifits": two
|
110 |
-
}
|
111 |
|
112 |
# Optionally, you can delete the temporary file after use
|
113 |
os.remove(image_path)
|
114 |
|
115 |
-
return
|
116 |
|
117 |
# Create Gradio interface
|
118 |
demo = gr.Interface(
|
|
|
43 |
}
|
44 |
'''
|
45 |
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
def process_document(image):
|
50 |
+
# Save the uploaded image to a temporary file
|
51 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as tmp_file:
|
52 |
+
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
53 |
+
image.save(tmp_file.name) # Save the image to the temporary file
|
54 |
+
image_path = tmp_file.name # Get the path of the saved file
|
55 |
+
|
56 |
+
|
57 |
+
messages = [
|
58 |
{
|
59 |
"role": "user",
|
60 |
"content": [
|
|
|
102 |
json = literal_eval(almost_json)
|
103 |
except:
|
104 |
json = output_text[0] # Return raw output if JSON parsing fails
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
# Optionally, you can delete the temporary file after use
|
107 |
os.remove(image_path)
|
108 |
|
109 |
+
return json
|
110 |
|
111 |
# Create Gradio interface
|
112 |
demo = gr.Interface(
|