LPX55 commited on
Commit
41bcba4
·
verified ·
1 Parent(s): a03b87b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -110,8 +110,8 @@ def predict_image(img, confidence_threshold):
110
  logits_3 = outputs_3.logits
111
  probabilities_3 = softmax(logits_3.cpu().numpy()[0])
112
  result_3 = {
113
- labels_3[1]: float(probabilities_3[1]) # Real
114
- labels_3[0]: float(probabilities_3[0]), # AI
115
  }
116
  print(result_3)
117
  # Ensure the result dictionary contains all class names
@@ -136,8 +136,8 @@ def predict_image(img, confidence_threshold):
136
  logits_4 = outputs_4.logits
137
  probabilities_4 = softmax(logits_4.cpu().numpy()[0])
138
  result_4 = {
139
- labels_4[1]: float(probabilities_4[1]) # Real
140
- labels_4[0]: float(probabilities_4[0]), # AI
141
  }
142
  print(result_4)
143
  # Ensure the result dictionary contains all class names
@@ -156,7 +156,12 @@ def predict_image(img, confidence_threshold):
156
 
157
  try:
158
  img_bytes = convert_pil_to_bytes(img_pil)
 
 
 
 
159
  response5_raw = call_inference(img_bytes)
 
160
  response5 = response5_raw.json()
161
  print(response5)
162
  label_5 = f"Result: {response5}"
@@ -215,11 +220,11 @@ with gr.Blocks() as iface:
215
  gr.Markdown("# AI Generated Image Classification")
216
 
217
  with gr.Row():
218
- with gr.Column():
219
  image_input = gr.Image(label="Upload Image to Analyze", sources=['upload'], type='pil')
220
  confidence_slider = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Confidence Threshold")
221
  inputs = [image_input, confidence_slider]
222
- with gr.Column():
223
  image_output = gr.Image(label="Processed Image")
224
  # Custom HTML component to display results in 5 columns
225
  results_html = gr.HTML(label="Model Predictions")
 
110
  logits_3 = outputs_3.logits
111
  probabilities_3 = softmax(logits_3.cpu().numpy()[0])
112
  result_3 = {
113
+ labels_3[1]: float(probabilities_3[1]), # Real
114
+ labels_3[0]: float(probabilities_3[0]) # AI
115
  }
116
  print(result_3)
117
  # Ensure the result dictionary contains all class names
 
136
  logits_4 = outputs_4.logits
137
  probabilities_4 = softmax(logits_4.cpu().numpy()[0])
138
  result_4 = {
139
+ labels_4[1]: float(probabilities_4[1]), # Real
140
+ labels_4[0]: float(probabilities_4[0]) # AI
141
  }
142
  print(result_4)
143
  # Ensure the result dictionary contains all class names
 
156
 
157
  try:
158
  img_bytes = convert_pil_to_bytes(img_pil)
159
+
160
+ print(img_pill)
161
+ print(img_bytes)
162
+
163
  response5_raw = call_inference(img_bytes)
164
+ print(response5_raw)
165
  response5 = response5_raw.json()
166
  print(response5)
167
  label_5 = f"Result: {response5}"
 
220
  gr.Markdown("# AI Generated Image Classification")
221
 
222
  with gr.Row():
223
+ with gr.Column(scale=2):
224
  image_input = gr.Image(label="Upload Image to Analyze", sources=['upload'], type='pil')
225
  confidence_slider = gr.Slider(0.0, 1.0, value=0.5, step=0.01, label="Confidence Threshold")
226
  inputs = [image_input, confidence_slider]
227
+ with gr.Column(scale=3):
228
  image_output = gr.Image(label="Processed Image")
229
  # Custom HTML component to display results in 5 columns
230
  results_html = gr.HTML(label="Model Predictions")