arham061 commited on
Commit
c7cae0c
1 Parent(s): 10fbe99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -28,16 +28,20 @@ def play_game(img):
28
  user_choice = max(user_probs, key=user_probs.get)
29
  computer_choice = random.choice(categories)
30
  winner = determine_winner(user_choice, computer_choice)
31
- computer_image = random.choice(get_image_files(f'{computer_choice}.jpg'))
32
  return f"User's choice: {user_choice}\nComputer's choice: {computer_choice}\n{winner}", computer_image
33
 
34
 
35
  image = gr.inputs.Image(shape=(192, 192), label="User's Image")
36
  label = gr.outputs.Label(label="Game Result")
 
 
 
 
37
 
38
  examples = ['rock.jpg', 'paper.jpg', 'scissor.jpg']
39
 
40
- intf = gr.Interface(fn=play_game, inputs=image, outputs=label, examples=examples, capture_session=True)
41
  intf.blocks[0].block_id = 0 # Unique ID for the image input block
42
  intf.blocks[1].block_id = 1 # Unique ID for the label output block
43
  intf.launch(inline=False)
 
28
  user_choice = max(user_probs, key=user_probs.get)
29
  computer_choice = random.choice(categories)
30
  winner = determine_winner(user_choice, computer_choice)
31
+ computer_image = get_image_files(f'{computer_choice}.jpg')
32
  return f"User's choice: {user_choice}\nComputer's choice: {computer_choice}\n{winner}", computer_image
33
 
34
 
35
  image = gr.inputs.Image(shape=(192, 192), label="User's Image")
36
  label = gr.outputs.Label(label="Game Result")
37
+ output = gr.outputs.MultiOutput(
38
+ label=gr.outputs.Label(label="Game Result"),
39
+ image=gr.outputs.Image(label="Computer's Image")
40
+ )
41
 
42
  examples = ['rock.jpg', 'paper.jpg', 'scissor.jpg']
43
 
44
+ intf = gr.Interface(fn=play_game, inputs=image, outputs= output, examples=examples, capture_session=True)
45
  intf.blocks[0].block_id = 0 # Unique ID for the image input block
46
  intf.blocks[1].block_id = 1 # Unique ID for the label output block
47
  intf.launch(inline=False)