Spaces:
Running on CPU Upgrade

osv5m commited on
Commit
4b6b8fe
1 Parent(s): 4738657

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -411,27 +411,27 @@ class Engine(object):
411
  return self.load_image()
412
 
413
  def get_model_average(self, which, all=False, final=False):
414
- aux, i = [], self.index+int(not final)
415
  if which == 'user':
416
  avg_score = sum(self.stats['scores']) / len(self.stats['scores']) if self.stats['scores'] else 0
417
  avg_distance = sum(self.stats['distances']) / len(self.stats['distances']) if self.stats['distances'] else 0
418
- avg_country_accuracy = (0 if self.df['country_val'].iloc[:i].sum() == 0 else sum(self.stats['country'])/self.df['country_val'].iloc[:i].sum())*100
419
  if all:
420
- avg_city_accuracy = (0 if self.df['city_val'].iloc[:i].sum() == 0 else sum(self.stats['city'])/self.df['city_val'].iloc[:i].sum())*100
421
- avg_area_accuracy = (0 if self.df['area_val'].iloc[:i].sum() == 0 else sum(self.stats['area'])/self.df['area_val'].iloc[:i].sum())*100
422
- avg_region_accuracy = (0 if self.df['region_val'].iloc[:i].sum() == 0 else sum(self.stats['region'])/self.df['region_val'].iloc[:i].sum())*100
423
  aux = [avg_city_accuracy, avg_area_accuracy, avg_region_accuracy]
424
  which = 'You'
425
  elif which == 'base':
426
- avg_score = np.mean(self.df[['score_base']].iloc[:i])
427
- avg_distance = np.mean(self.df[['distance_base']].iloc[:i])
428
  avg_country_accuracy = self.df['accuracy_country_base'].iloc[i]
429
  if all:
430
  aux = [self.df['accuracy_city_base'].iloc[i], self.df['accuracy_area_base'].iloc[i], self.df['accuracy_region_base'].iloc[i]]
431
  which = 'Baseline-AI'
432
  elif which == 'best':
433
- avg_score = np.mean(self.df[['score']].iloc[:i])
434
- avg_distance = np.mean(self.df[['distance']].iloc[:i])
435
  avg_country_accuracy = self.df['accuracy_country'].iloc[i]
436
  if all:
437
  aux = [self.df['accuracy_city_base'].iloc[i], self.df['accuracy_area_base'].iloc[i], self.df['accuracy_region_base'].iloc[i]]
 
411
  return self.load_image()
412
 
413
  def get_model_average(self, which, all=False, final=False):
414
+ aux, i = [], self.index
415
  if which == 'user':
416
  avg_score = sum(self.stats['scores']) / len(self.stats['scores']) if self.stats['scores'] else 0
417
  avg_distance = sum(self.stats['distances']) / len(self.stats['distances']) if self.stats['distances'] else 0
418
+ avg_country_accuracy = (0 if self.df['country_val'].iloc[:i+1].sum() == 0 else sum(self.stats['country'])/self.df['country_val'].iloc[:i+1].sum())*100
419
  if all:
420
+ avg_city_accuracy = (0 if self.df['city_val'].iloc[:i+1].sum() == 0 else sum(self.stats['city'])/self.df['city_val'].iloc[:i+1].sum())*100
421
+ avg_area_accuracy = (0 if self.df['area_val'].iloc[:i+1].sum() == 0 else sum(self.stats['area'])/self.df['area_val'].iloc[:i+1].sum())*100
422
+ avg_region_accuracy = (0 if self.df['region_val'].iloc[:i+1].sum() == 0 else sum(self.stats['region'])/self.df['region_val'].iloc[:i+1].sum())*100
423
  aux = [avg_city_accuracy, avg_area_accuracy, avg_region_accuracy]
424
  which = 'You'
425
  elif which == 'base':
426
+ avg_score = np.mean(self.df[['score_base']].iloc[:i+1])
427
+ avg_distance = np.mean(self.df[['distance_base']].iloc[:i+1])
428
  avg_country_accuracy = self.df['accuracy_country_base'].iloc[i]
429
  if all:
430
  aux = [self.df['accuracy_city_base'].iloc[i], self.df['accuracy_area_base'].iloc[i], self.df['accuracy_region_base'].iloc[i]]
431
  which = 'Baseline-AI'
432
  elif which == 'best':
433
+ avg_score = np.mean(self.df[['score']].iloc[:i+1])
434
+ avg_distance = np.mean(self.df[['distance']].iloc[:i+1])
435
  avg_country_accuracy = self.df['accuracy_country'].iloc[i]
436
  if all:
437
  aux = [self.df['accuracy_city_base'].iloc[i], self.df['accuracy_area_base'].iloc[i], self.df['accuracy_region_base'].iloc[i]]