Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Commit 
							
							Β·
						
						87d0d80
	
1
								Parent(s):
							
							3423e64
								
logs
Browse files- .gitignore +1 -0
- app.py +1 -1
- awesome_chat.py +13 -2
- demos/demo_parse_task.json +10 -1
    	
        .gitignore
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 | 
             
            logs/
         | 
|  | |
| 2 | 
             
            models
         | 
| 3 | 
             
            public/*
         | 
| 4 | 
             
            *.pyc
         | 
|  | |
| 1 | 
             
            logs/
         | 
| 2 | 
            +
            logs2/
         | 
| 3 | 
             
            models
         | 
| 4 | 
             
            public/*
         | 
| 5 | 
             
            *.pyc
         | 
    	
        app.py
    CHANGED
    
    | @@ -163,7 +163,7 @@ with gr.Blocks(css=css) as demo: | |
| 163 | 
             
                    with gr.Column(scale=0.85):
         | 
| 164 | 
             
                        txt = gr.Textbox(
         | 
| 165 | 
             
                            show_label=False,
         | 
| 166 | 
            -
                            placeholder="Enter text and press enter. The url  | 
| 167 | 
             
                            lines=1,
         | 
| 168 | 
             
                        ).style(container=False)
         | 
| 169 | 
             
                    with gr.Column(scale=0.15, min_width=0):
         | 
|  | |
| 163 | 
             
                    with gr.Column(scale=0.85):
         | 
| 164 | 
             
                        txt = gr.Textbox(
         | 
| 165 | 
             
                            show_label=False,
         | 
| 166 | 
            +
                            placeholder="Enter text and press enter. The url must contain the media type. e.g, https://example.com/example.jpg",
         | 
| 167 | 
             
                            lines=1,
         | 
| 168 | 
             
                        ).style(container=False)
         | 
| 169 | 
             
                    with gr.Column(scale=0.15, min_width=0):
         | 
    	
        awesome_chat.py
    CHANGED
    
    | @@ -1,5 +1,6 @@ | |
| 1 | 
             
            import base64
         | 
| 2 | 
             
            import copy
         | 
|  | |
| 3 | 
             
            from io import BytesIO
         | 
| 4 | 
             
            import io
         | 
| 5 | 
             
            import os
         | 
| @@ -23,6 +24,8 @@ from huggingface_hub.inference_api import InferenceApi | |
| 23 | 
             
            from huggingface_hub.inference_api import ALL_TASKS
         | 
| 24 | 
             
            from models_server import models, status
         | 
| 25 | 
             
            from functools import partial
         | 
|  | |
|  | |
| 26 |  | 
| 27 | 
             
            parser = argparse.ArgumentParser()
         | 
| 28 | 
             
            parser.add_argument("--config", type=str, default="config.yaml.dev")
         | 
| @@ -37,6 +40,12 @@ config = yaml.load(open(args.config, "r"), Loader=yaml.FullLoader) | |
| 37 | 
             
            if not os.path.exists("logs"):
         | 
| 38 | 
             
                os.mkdir("logs")
         | 
| 39 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 40 | 
             
            logger = logging.getLogger(__name__)
         | 
| 41 | 
             
            logger.setLevel(logging.DEBUG)
         | 
| 42 |  | 
| @@ -190,13 +199,15 @@ def get_id_reason(choose_str): | |
| 190 | 
             
                return id.strip(), reason.strip(), choose
         | 
| 191 |  | 
| 192 | 
             
            def record_case(success, **args):
         | 
|  | |
| 193 | 
             
                if success:
         | 
| 194 | 
            -
                    f = open("logs/log_success.jsonl", "a")
         | 
| 195 | 
             
                else:
         | 
| 196 | 
            -
                    f = open("logs/log_fail.jsonl", "a")
         | 
| 197 | 
             
                log = args
         | 
| 198 | 
             
                f.write(json.dumps(log) + "\n")
         | 
| 199 | 
             
                f.close()
         | 
|  | |
| 200 |  | 
| 201 | 
             
            def image_to_bytes(img_url):
         | 
| 202 | 
             
                img_byte = io.BytesIO()
         | 
|  | |
| 1 | 
             
            import base64
         | 
| 2 | 
             
            import copy
         | 
| 3 | 
            +
            import datetime
         | 
| 4 | 
             
            from io import BytesIO
         | 
| 5 | 
             
            import io
         | 
| 6 | 
             
            import os
         | 
|  | |
| 24 | 
             
            from huggingface_hub.inference_api import ALL_TASKS
         | 
| 25 | 
             
            from models_server import models, status
         | 
| 26 | 
             
            from functools import partial
         | 
| 27 | 
            +
            from huggingface_hub import Repository
         | 
| 28 | 
            +
            import huggingface_hub
         | 
| 29 |  | 
| 30 | 
             
            parser = argparse.ArgumentParser()
         | 
| 31 | 
             
            parser.add_argument("--config", type=str, default="config.yaml.dev")
         | 
|  | |
| 40 | 
             
            if not os.path.exists("logs"):
         | 
| 41 | 
             
                os.mkdir("logs")
         | 
| 42 |  | 
| 43 | 
            +
            DATASET_REPO_URL = "https://huggingface.co/datasets/tricktreat/HuggingGPT_logs"
         | 
| 44 | 
            +
            LOG_HF_TOKEN = os.environ.get("LOG_HF_TOKEN")
         | 
| 45 | 
            +
            repo = Repository(
         | 
| 46 | 
            +
                local_dir="logs", clone_from=DATASET_REPO_URL, use_auth_token=LOG_HF_TOKEN
         | 
| 47 | 
            +
            )
         | 
| 48 | 
            +
             | 
| 49 | 
             
            logger = logging.getLogger(__name__)
         | 
| 50 | 
             
            logger.setLevel(logging.DEBUG)
         | 
| 51 |  | 
|  | |
| 199 | 
             
                return id.strip(), reason.strip(), choose
         | 
| 200 |  | 
| 201 | 
             
            def record_case(success, **args):
         | 
| 202 | 
            +
                # time format
         | 
| 203 | 
             
                if success:
         | 
| 204 | 
            +
                    f = open(f"logs/log_success.jsonl", "a")
         | 
| 205 | 
             
                else:
         | 
| 206 | 
            +
                    f = open(f"logs/log_fail.jsonl", "a")
         | 
| 207 | 
             
                log = args
         | 
| 208 | 
             
                f.write(json.dumps(log) + "\n")
         | 
| 209 | 
             
                f.close()
         | 
| 210 | 
            +
                commit_url = repo.push_to_hub()
         | 
| 211 |  | 
| 212 | 
             
            def image_to_bytes(img_url):
         | 
| 213 | 
             
                img_byte = io.BytesIO()
         | 
    	
        demos/demo_parse_task.json
    CHANGED
    
    | @@ -61,5 +61,14 @@ | |
| 61 | 
             
                {
         | 
| 62 | 
             
                    "role": "assistant",
         | 
| 63 | 
             
                    "content": "[{\"task\": \"text-to-image\", \"id\": 0, \"dep\": [-1], \"args\": {\"text\": \"a picture of a cut dog\" }}, {\"task\": \"image-to-text\", \"id\": 1, \"dep\": [0], \"args\": {\"image\": \"<GENERATED>-0\" }}, {\"task\": \"text-generation\", \"id\": 2, \"dep\": [1], \"args\": {\"text\": \"<GENERATED>-1\" }}, {\"task\": \"text-to-speech\", \"id\": 3, \"dep\": [2], \"args\": {\"text\": \"<GENERATED>-2\" }}]"
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 64 | 
             
                }
         | 
| 65 | 
            -
            ]
         | 
|  | |
| 61 | 
             
                {
         | 
| 62 | 
             
                    "role": "assistant",
         | 
| 63 | 
             
                    "content": "[{\"task\": \"text-to-image\", \"id\": 0, \"dep\": [-1], \"args\": {\"text\": \"a picture of a cut dog\" }}, {\"task\": \"image-to-text\", \"id\": 1, \"dep\": [0], \"args\": {\"image\": \"<GENERATED>-0\" }}, {\"task\": \"text-generation\", \"id\": 2, \"dep\": [1], \"args\": {\"text\": \"<GENERATED>-1\" }}, {\"task\": \"text-to-speech\", \"id\": 3, \"dep\": [2], \"args\": {\"text\": \"<GENERATED>-2\" }}]"
         | 
| 64 | 
            +
                },
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                {
         | 
| 67 | 
            +
                    "role": "user",
         | 
| 68 | 
            +
                    "content": "give you a picture /example.jpg, what's in it and tell me a joke about it"
         | 
| 69 | 
            +
                },
         | 
| 70 | 
            +
                {
         | 
| 71 | 
            +
                    "role": "assistant",
         | 
| 72 | 
            +
                    "content": "[{\"task\": \"image-to-text\", \"id\": 0, \"dep\": [-1], \"args\": {\"image\": \"/example.jpg\" }}, {\"task\": \"object-detection\", \"id\": 1, \"dep\": [-1], \"args\": {\"image\": \"/example.jpg\" }}, {\"task\": \"conversational\", \"id\": 2, \"dep\": [0], \"args\": {\"text\": \"<GENERATED>-0\" }}, {\"task\": \"text-to-speech\", \"id\": 3, \"dep\": [2], \"args\": {\"text\": \"<GENERATED>-1\" }}]"
         | 
| 73 | 
             
                }
         | 
| 74 | 
            +
            ]
         | 
