Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,8 +41,8 @@ def generate_captions_from_image(image):
|
|
| 41 |
if image.mode != "RGB":
|
| 42 |
image = image.convert("RGB")
|
| 43 |
|
| 44 |
-
# Resize image for faster processing
|
| 45 |
-
image = image.resize((
|
| 46 |
|
| 47 |
# Preprocess the image and generate a caption
|
| 48 |
inputs = processor(image, return_tensors="pt").to(device, torch.float16)
|
|
@@ -146,7 +146,6 @@ def upload_file_to_salesforce(file_path, filename, sf_connection, file_type):
|
|
| 146 |
except Exception as e:
|
| 147 |
return None, None, f"Error uploading {filename} to Salesforce: {str(e)}"
|
| 148 |
|
| 149 |
-
# Function to generate the daily progress report (DPR), save as PDF, and upload to Salesforce
|
| 150 |
# Function to generate the daily progress report (DPR), save as PDF, and upload to Salesforce
|
| 151 |
def generate_dpr(files):
|
| 152 |
dpr_text = []
|
|
@@ -249,7 +248,6 @@ def generate_dpr(files):
|
|
| 249 |
dpr_output + f"\n\n{pdf_result}\n\nSalesforce Upload Status:\n{salesforce_result}",
|
| 250 |
pdf_filepath
|
| 251 |
)
|
| 252 |
-
|
| 253 |
# Gradio interface for uploading multiple files, displaying DPR, and downloading PDF
|
| 254 |
iface = gr.Interface(
|
| 255 |
fn=generate_dpr,
|
|
|
|
| 41 |
if image.mode != "RGB":
|
| 42 |
image = image.convert("RGB")
|
| 43 |
|
| 44 |
+
# Resize image for faster processing (use smaller resolution to speed up inference)
|
| 45 |
+
image = image.resize((320, 320)) # Reduced size for faster processing
|
| 46 |
|
| 47 |
# Preprocess the image and generate a caption
|
| 48 |
inputs = processor(image, return_tensors="pt").to(device, torch.float16)
|
|
|
|
| 146 |
except Exception as e:
|
| 147 |
return None, None, f"Error uploading {filename} to Salesforce: {str(e)}"
|
| 148 |
|
|
|
|
| 149 |
# Function to generate the daily progress report (DPR), save as PDF, and upload to Salesforce
|
| 150 |
def generate_dpr(files):
|
| 151 |
dpr_text = []
|
|
|
|
| 248 |
dpr_output + f"\n\n{pdf_result}\n\nSalesforce Upload Status:\n{salesforce_result}",
|
| 249 |
pdf_filepath
|
| 250 |
)
|
|
|
|
| 251 |
# Gradio interface for uploading multiple files, displaying DPR, and downloading PDF
|
| 252 |
iface = gr.Interface(
|
| 253 |
fn=generate_dpr,
|