| | |
| | import argparse |
| | import os |
| | from model_utils import SkinGPTModel |
| |
|
| | def main(): |
| | parser = argparse.ArgumentParser(description="SkinGPT-R1 Multi-turn Chat") |
| | parser.add_argument("--model_path", type=str, default="../checkpoint") |
| | parser.add_argument("--image", type=str, required=True, help="Path to initial image") |
| | args = parser.parse_args() |
| |
|
| | |
| | bot = SkinGPTModel(args.model_path) |
| |
|
| | |
| | |
| | system_prompt = "You are a professional AI dermatology assistant. Analyze the skin condition carefully." |
| | |
| | |
| | if not os.path.exists(args.image): |
| | print(f"Error: Image {args.image} not found.") |
| | return |
| |
|
| | history = [ |
| | { |
| | "role": "user", |
| | "content": [ |
| | {"type": "image", "image": args.image}, |
| | {"type": "text", "text": f"{system_prompt}\n\nPlease analyze this image."} |
| | ] |
| | } |
| | ] |
| |
|
| | print("\n=== SkinGPT-R1 Chat (Type 'exit' to quit) ===") |
| | print(f"Image loaded: {args.image}") |
| | |
| | |
| | print("\nModel is thinking...", end="", flush=True) |
| | response = bot.generate_response(history) |
| | print(f"\rAssistant: {response}\n") |
| | |
| | |
| | history.append({"role": "assistant", "content": [{"type": "text", "text": response}]}) |
| |
|
| | |
| | while True: |
| | try: |
| | user_input = input("User: ") |
| | if user_input.lower() in ["exit", "quit"]: |
| | break |
| | if not user_input.strip(): |
| | continue |
| |
|
| | |
| | history.append({"role": "user", "content": [{"type": "text", "text": user_input}]}) |
| |
|
| | print("Model is thinking...", end="", flush=True) |
| | response = bot.generate_response(history) |
| | print(f"\rAssistant: {response}\n") |
| |
|
| | |
| | history.append({"role": "assistant", "content": [{"type": "text", "text": response}]}) |
| |
|
| | except KeyboardInterrupt: |
| | break |
| |
|
| | if __name__ == "__main__": |
| | main() |