xtlyxt commited on
Commit
dee92a9
·
verified ·
1 Parent(s): 179beb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -1,4 +1,3 @@
1
- #working code
2
  import streamlit as st
3
  from PIL import Image
4
  from transformers import pipeline
@@ -134,14 +133,9 @@ if st.button("Generate HeatMap & DataFrame"):
134
  worksheet = writer.sheets['Sheet1']
135
 
136
  # Set the column width and row height
137
- worksheet.set_column('A:G', 8) # Set width for columns A-G
138
- worksheet.set_column('H:H', 22) # Set width for column H (Image Name)
139
- worksheet.set_column('I:I', 14) # Set width for column I (Image Size)
140
- worksheet.set_column('J:J', 12) # Set width for column J (Image View)
141
- worksheet.set_column('K:K', 12) # Set width for column K (Image Num)
142
-
143
-
144
-
145
  for row_num in range(len(df_emotions) + 1): # +1 to include the header row
146
  worksheet.set_row(row_num, 38) # Set the row height to 38
147
 
@@ -151,7 +145,18 @@ if st.button("Generate HeatMap & DataFrame"):
151
  image_stream = io.BytesIO()
152
  image.save(image_stream, format='PNG')
153
  image_stream.seek(0)
154
- worksheet.insert_image(f'J{idx + 2}', 'image.png', {'image_data': image_stream})
 
 
 
 
 
 
 
 
 
 
 
155
 
156
  # Close the writer object
157
  writer.close()
 
 
1
  import streamlit as st
2
  from PIL import Image
3
  from transformers import pipeline
 
133
  worksheet = writer.sheets['Sheet1']
134
 
135
  # Set the column width and row height
136
+ worksheet.set_column('A:I', 20) # Set width for columns A-I
137
+ worksheet.set_column('J:J', 30) # Set width for column J (Image View)
138
+ worksheet.set_column('K:K', 15) # Set width for column K (Image Num)
 
 
 
 
 
139
  for row_num in range(len(df_emotions) + 1): # +1 to include the header row
140
  worksheet.set_row(row_num, 38) # Set the row height to 38
141
 
 
145
  image_stream = io.BytesIO()
146
  image.save(image_stream, format='PNG')
147
  image_stream.seek(0)
148
+ # Calculate the scaling factor to fit the image inside the cell
149
+ cell_width = 64
150
+ scale_factor = cell_width / image.width
151
+ # Insert the image into the cell
152
+ worksheet.insert_image(f'J{idx + 2}', 'image.png', {
153
+ 'image_data': image_stream,
154
+ 'x_scale': scale_factor,
155
+ 'y_scale': scale_factor,
156
+ 'x_offset': 2,
157
+ 'y_offset': 2,
158
+ 'positioning': 1
159
+ })
160
 
161
  # Close the writer object
162
  writer.close()